Using single-command docker image in another docker image (php, nodejs, phantomjs) - docker

I have two docker images: php and phantomjs.
Im using them to build simple command-line script application.
Also im having convinient run.bat script that contains:
docker run -it --rm --name my-running-script -v %cd%:/usr/src/myapp -w /usr/src/myapp php:7.0-cli php
What should i do to add nodejs into my php image?
I want to be able to use something like "phantomjs --help" inside php container.
I've tried to search documentation for similar issues, but havent found any tips on that.
This is phantomjs image that im using: https://hub.docker.com/r/wernight/phantomjs/
for php image im using:
https://hub.docker.com/_/php/

If you want phantomjs inside your php container, instead of using two docker images one with php and other with phantomjs you just need to build your own cutom docker image with both these packages.
It seems you are using debian:stretch as base image for phantomjs https://hub.docker.com/r/wernight/phantomjs/~/dockerfile/
You just need to google for installing php on debian. Probably it should be one more line in your dockerfile apt-get install -y php. Then build this image and use it.

Related

docker in docker via bind mound - ubuntu

I need to have an ubuntu image and then run a build process using that image. All is well until the build gets to the point of doing docker build etc.
Lets say I use the following to test this:
Dockerfile
FROM ubuntu:latest
I then build that - docker build -t ubuntudkr .
Next, I run it like:
docker run -ti -v /var/run/docker.sock:/var/run/docker.sock ubuntudkr
When I then run docker ps inside this container, I get the error bash: docker: command not found
All the examples I've found says I need to run:
docker run -v /var/run/docker.sock:/var/run/docker.sock \
-ti docker
They all use the docker image which contains the docker library. Is my answer then to install docker inside my base image to make it work? Does this then not go against what docker themselves says?
There are many other blog posts out there that gave the same advice, but my example does work. Where do I go wrong?
Replace the image ubuntu:latest in your dockerfile by the official docker:latest image wich contains docker binaries and does exactly what you want: https://hub.docker.com/_/docker
If you want to keep the Ubuntu image, you must install Docker tools following your error. By default, the Ubuntu image does not contain Docker binaries as a regular Ubuntu installation.

Dev environnement for gcc with Docker?

I would like to create a minimalist dev environment for occasional developers which only need Docker.
The ecosystem would have:
code-server image to run Visual Studio Code
gcc image to build the code
git to push/commit the code
ubuntu with some modifications to run the code
I looked to docker-in-docker which could be a solution:
Docker
code-server
docker run -it -v ... gcc make
docker run -it -v ... git git commit ...
docker run -it -v ... ubuntu ./program
But it seems perhaps a bit overkill. What would be the proper way to have a full dev environment well separated, that only require Docker to be installed on the host machine (Linux, Windows, MacOS, Chromium)
I suggest using a Dockerfile.
This file specifies a few steps used to build an image.
The first line of the file specifies a base image(in your case, I would use Ubuntu):
FROM ubuntu:latest
Then, you can e.g. copy files to the image or select commands to run:
RUN apt install gcc make
RUN apt install git
and so on.
At the end, you may want to specify the program that is run when you start the container
CMD /bin/bash
Then you can build it with the command docker build -f Dockerfile -t devenv:latest. This builds a new image named devenv:latest (latest is the version) from the file Dockerfile.
Then, you can create a container from the file using docker run devenv:latest.
If you want to use this container multiple times, you could create it using docker run -it devenv:latest
If you want to, you can also use the code-server base image instead of ubuntu:latest.

How to run Dockerfile or Dock Image to install the python dependencies

Sorry for basic Question, as I am new on Docker and I want to install the dependencies by using the docker file, So please guide me how to run this file on Ubuntu?
Author have written the dependencies in the Dockerfile for building the Opensfm.
GitHub Repository Link
FROM ubuntu:18.04
# Install apt-getable dependencies
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y \
build-essential \
Can anyone guide me how to run the file and install the dependencies on Ubuntu?
You really should follow mchawre's advice and read the docker get-started. However, I can try to direct you into the right direction.
I want to install the dependencies by using the docker file
You have to understand that a docker file compiles to a docker image which then can be run as a docker container. You can think of a docker container as a lightweight virtual machine. With this in mind, your statement does not make sense, since you can not install dependencies for your host system (the system in which you might want to start the docker container) with the help of a docker image. This is not how docker containers are supposed to work.
Instead, the docker file allows you to create a virtualized (isolated) environment in which you can ssh (the docker way: docker exec -it <container_name> bash) and then build the respective application.
If you do not want to mess with docker at all and your systems runs something close to ubuntu:18.04, you can also manually execute the instruction from the docker file on your normal system in order to build your desired application on your system.

Docker - how to add new python dependencies to the existing docker image?

I am a novice to docker.
I am having difficulty using tensorflow docker in my Windows 10 OS.
As I am following the Udacity's deep learning course, I've downloaded the tensorflow docker following the instruction and tried to launch the first assignment.
But it failed to launch as the docker image was missing the scikit-learn package.
So basically what I do to overcome this issue is I first run my docker image:
docker run -it -p 8888:8888 b.gcr.io/tensorflow/tensorflow /bin/bash
and then I run:
pip install -U scikit-learn
and then I run (might not be 100% correct but something like):
./run_jupyter.sh
to launch the iPython notebook to carry on my assignment.
My question is simple:
how do I save this change that I occurred on this docker image so I don't have to repeat this step each time I have to relaunch the notebook?
Can I do this by modifying the docker configuration file?
Once your container is in the right state (scikit-learn is installed, the script is executed), stop it (docker stop) and commit it as a new image.
See docker commit in order to commit a container’s file changes or settings into a new image.
Then you can run that new image (with the same parameters as before), except the container created from that new image will have the previous steps already there.
But the other approach is to build your image from the tenserflow udacity Dockerfile.
FROM gcr.io/tensorflow/tensorflow:latest
MAINTAINER Vincent Vanhoucke <vanhoucke#google.com>
RUN pip install scikit-learn
RUN rm -rf /notebooks/*
ADD *.ipynb /notebooks/
WORKDIR /notebooks
CMD ["/run_jupyter.sh"]
That image, by default, will execute the right command.

I want to create a Docker image which contains Java and PostgreSQL. I just want to create an Image to reuse it from anywhere

I want to create a Docker image which contains Java and PostgreSQL. I just want to create an Image to reuse it from anywhere.
From reading the documentation I don't understand how I can do that.
This is what I tried:
user#host:/$ docker run -i -t debian /bin/bash
root#container:/$ apt-get install postgresql-9.3
user#host:/$ docker ps
user#host:/$ docker commit <CID> username/postgresql
Why reinvent the wheel ? If you look at the registry, it already exists, see
https://registry.hub.docker.com/u/alinous/docker-java-postgresql/
Another way, you can also add PostgreSQL to a Java container, like this one
https://registry.hub.docker.com/u/dockerfile/java/ or add Java to a PostgreSQL container...
so start your Dockerfile with from dockerfile/java

Resources