The dind (Docker IN Docker) pulled from DockerHub works fine, but I cannot build the dind from scratch.
I tried to build as follows.
My Docker version is 1.1.
$ git clone https://github.com/docker-library/docker
$ cd docker/
$ cd 1.1/
$ docker build -t docker:dind .
I could create a "dind" Docker image. After that I tried to run.
$ docker run -it --privileged --name test -d docker:dind
52e590b6636b3726bbe9774627f4424c2b9f8958a745d57c27d04cbec77a2d7b
$ docker run -it --rm --link test:docker docker run -it ubuntu bash
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
The dind did not work well.
So, I tried to customize from the dind pulled from Docker Hub.
$ docker pull docker:dind
$ docker run -it docker:dind ash
/ # exit
$ docker commit d508c2fd7131 docker:dind
sha256:f20e0314f996fe9f66806df47c1bdff956c84d11a6bfe2ff66279bee968323ec
$ docker run -it --privileged --name test -d docker:dind
d877c1993275fd4039b749f52d60a3095d40d52e13255c4fd88a319ca7ec306a
$ docker run -it --rm --link test:docker docker run -it ubuntu bash
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
It also had same problem. I just run the "dind" on Docker and exit immediately.
I cannot understand why I cannot customize the "dind" image.
Please tell me how to fix this problem.
Try this.
docker run --privileged -d --name test docker:dind
docker exec -it test docker version
docker commit test mydind
You can use mydind image
Related
I am trying to run an image with a given container name.
How to achieve this?
I am running this command:
docker run -it -d macgyvertechnology/tensorflow-gpu:basic-jupyter --name hugging-face-models-run --gpus all
Docker run command format:
$ docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
You need to update your command to
$ docker run -it -d --name hugging-face-models-run --gpus all macgyvertechnology/tensorflow-gpu:basic-jupyter
Reference:
https://docs.docker.com/engine/reference/commandline/run/#usage
For CI/CD purposes, I need docker in docker:
docker network create some-network
docker volume create some-docker-certs-ca
docker volume create some-docker-certs-client
docker run --privileged --name some-dind -d --network some-network --network-alias docker -e DOCKER_TLS_CERTDIR=/certs -v some-docker-certs-ca:/certs/ca -v some-docker-certs-client:/certs/client docker:dind
Now if I run the docker:latest image with -it option, I can use docker in the container as expected:
docker run --rm -it --network some-network -e DOCKER_TLS_CERTDIR=/certs -v some-docker-certs-client:/certs/client:ro docker:latest sh
/ # docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
/ #
But I need to customize docker:latest image in a Dockerfile:
FROM docker:latest
# install package1
# install package2
# install package3
...
# install package4
And build the customized docker image:
docker build -t customized-docker .
But when I run the customized-docker image with -it options, It cannot connect to docker daemon:
docker run --rm -it --network some-network -e DOCKER_TLS_CERTDIR=/certs -v some-docker-certs-client:/certs/client:ro customized-docker:latest sh
/ # docker ps
Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?
/ #
What is the problem? Isn't there any way I can use customized docker image?
Edit:
I found a better way to do my CI/CD without "docker in docker". As David Maze mentioned, most of the times, there is no need to use "docker in docker". But my question still remains: Why can the docker:latest container connect to docker daemon but a customized docker container cannot.
Docker is not started even if the subsequent command is executed.
docker pull incendonet/centos7-mono-apache
Even if you check with docker ps, it does not exist.
Please tell me the cause.
Docker will be started after you run below command :
docker run -it -d image-name
docker run -it -d incendonet/centos7-mono-apache
docker pull command just fetches image from docker hub to your server/local machine. But to run it you need to use docker run.
Once it is running then it will be shown in your docker ps command and you can use below command to get into container's shell :
docker exec -it <container-id> /bin/bash
I face this strange issue and can't explain why.
$ docker run -d --name dind --privileged --net=host -v `pwd`:/app -w /app docker:stable-dind
fe66d6e7e5effcf15e439a332a2368fddab810e9bc8ac3445392c8e56b0aa38a
$ docker exec dind ls
Dockerfile
$ docker exec dind docker run -v `pwd`:/app -w /app alpine ls
$ docker exec dind docker build -t demo .
Sending build context to Docker daemon 521.7kB
Step 1/24 : FROM alpine
So why I can't see my files in docker container which running in docker?
Why it can read the file Dockerfile with command docker build, but not docker run?
This is because pwd in your code will be parsed in your host machine, not in the container, so the container which in the container get the current directory of host machine, not current directory of container machine, you can prove it by change following command from:
$ docker exec dind docker run -v `pwd`:/app -w /app alpine ls
to
$ docker exec dind docker run -v /app:/app -w /app alpine ls
Then, you will see your Dockerfile output. FYI.
My OS is Windows 10 and docker version 17.12.0-ce, build c97c6d6.
Here is my plan:
0. Get containers
docker pull tendermint/tendermint
docker pull tendermint/monitor
1. Init container
docker run --rm -p 46657:46657 --name tendermint_bc -v "C:/Users/user/sandbox/tendermind/tmdata:/tendermint" tendermint/tendermint init
2. Start container
docker run --rm -d -v "C:/Users/user/sandbox/tendermind/tmdata:/tendermint" tendermint/tendermint node --proxy_app=dummy
3. Start tendemint monitor
docker run -it --rm --link=tm tendermint/monitor tendermint_bc:46657
By start of tendermint container I see only one hash, but by docker ps -a container is not listed.
If I run docker logs tendermint_bc, result is:
Error response from daemon: No such container: tendermint_bc
Same workflow on Unix work fine.
Thx for help.
In step 1, you are initializing Tendermint, but not running it. To run it, execute:
docker run --rm -p 46657:46657 --name tendermint_bc -v "C:/Users/user/sandbox/tendermind/tmdata:/tendermint" tendermint/tendermint node --proxy_app=dummy