Can not pull docker image - docker

I want to pull ubuntu image , but there is some errors shown
wangyaos-MBP-3:test wangyao$ sudo docker pull dl.dockerpool.com:5000/ubuntu:12.04
Post http:///var/run/docker.sock/v1.19/images/create?fromImage=dl.dockerpool.com%3A5000%2Fubuntu%3A12.04: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
but i can pull it in using $docker run ubuntu:14.04 grep -v '^#' /etc/apt/sources.list, it' too slowly.
How could I do to make it work ?

So your docker daemon is running with TLS and you are trying to connect without TLS(certificates). To check follow steps:-
boot2docker ssh - It will ssh to vm where docker daemon is running
ps -eaf | grep docker - check docker running with TLS and certificates.
You have 2 options -
Export DOCKER_CERT_PATH and DOCKER_TLS_VERIFY using $(boot2docker shellinit)
Or Start docker daemon without TLS.
Option 1
Run command $(boot2docker shellinit), it will set DOCKER_CERT_PATH and DOCKER_TLS_VERIFY for you and you will be able to run command.
Option 2
Follow steps -
boot2docker ssh
ps -eaf | grep docker - Get the PID of docker daemon running
sudo kill -9
docker -d -H unix:// -H tcp://0.0.0.0:2375 --insecure-registry dl.dockerpool.com:5000 &
exit from vm
export DOCKER_CERT_PATH=""
export DOCKER_TLS_VERIFY=""
export DOCKER_HOST=tcp://127.0.0.1:2375
Try to run docker pull command. It should work.
To summarize, if your docker daemon is running with TLS, you have to set certificate path and enable TLS. If your docker daemon is running without certificate then you will have to unset certificate and TLS(if set).

Related

jenkins in docker - Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I'm running https://hub.docker.com/r/jenkinsci/blueocean/ in docker. Trying to build a docker image in jenkins.
but i get the following error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
clearly the jenkins version in docker does not have access to the docker binary.
I confirmed this by,
docker exec -it db4292380977 bash
docker images
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
"db4292380977" is the running container. It shows the same error.
Question:
how do I allow access to docker in the jenkins container?
The docker client is installed on the jenkinsci/blueocean image, but not the daemon. Docker client will use the daemon (by default via the socket unix:///var/run/docker.sock). Docker client needs a Docker daemon in order to work, you can read Docker Architecture for more info.
What you can do:
Use docker-in-docker (DinD) image
Library Docker image provides a way to run a Docker daemon in Docker, you can then use it from another container. For example, using plain docker CLI:
docker run --name docker-dind --privileged -d docker:stable-dind
docker run --name jenkins --link=docker-dind -d jenkinsci/blueocean
docker exec jenkins docker -H docker-dind images
REPOSITORY TAG IMAGE ID CREATED SIZE
Docker daemon runs in docker-dind container and can be reached using the same hostname. You just need to provide the docker client with the daemon host (-H docker-dind in the example, you can also use DOCKER_HOST env variable as described in the doc).
Mount host machine /var/run/docker.sock in your container
As described by #Herman Garcia answer:
docker run -p 8080:8080 --user root \
-v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueocean
You need to mount your local /var/run/docker.sock and run the container as root user
NOTE: this might be a security flaw so be careful who has access to the jenkins container
docker run -p 8080:8080 --user root \
-v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueocean
you will be able to execute docker inside the container
➜ ~ docker exec -it gracious_agnesi bash
bash-4.4# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
c4dc85b0d88c jenkinsci/blueocean "/sbin/tini -- /usr/…" 18 seconds ago Up 16 seconds 0.0.0.0:8080->8080/tcp, 50000
/tcp gracious_agnesi
Just only try to do the same command but with sudo in the beginning
For example
sudo docker images
sudo docker exec -it db4292380977 bash
To avoid use sudo in the future you should run this command in Unix O.S
sudo usermod -aG docker <your-user>
Change for the user that you are using at this moment. Remember to log out and back in for this to take effect! More information about Docker installation click here

Docker in Docker(DND) is not starting

I have a simple Ubuntu 16.10 container which has docker.io installed.
The docker process terminates after it starts and log has this information. Any troubleshooting suggestions?
$ docker run -it --name dcos-ubuntu-python5 python-docker /bin/bash
root#5ff6bb6b6dc7:/# docker run hello-world
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
root#5ff6bb6b6dc7:/# service docker start
* Starting Docker: docker [ OK ]
root#5ff6bb6b6dc7:/# service docker status
* Docker is not running
root#5ff6bb6b6dc7:/# tail -f /var/log/docker.log
time="2017-12-21T17:09:45.464736873Z" level=info msg="libcontainerd: new containerd process, pid: 50"
time="2017-12-21T17:09:46.472578239Z" level=fatal msg="Error starting daemon: error initializing graphdriver: operation not permitted"
Why do you want to run docker within docker container?
Docker-in-Docker is developed to help docker development. And it needs --privileged flag to run docker container.(Please read jpetazzo's blog here.)
If you really want to execute docker in docker container, you also have other options.
Bind mount docker.sock. Some people call this DooD(Docker-outside-of-Docker)
docker run -v /var/run/docker.sock:/var/run/docker.sock ...
Install docker(client) and specify DOCKER_HOST to access remote docker daemon. Be careful about socket protection with certificates.
Are you running docker as sudo if not run as sudo or
Else add user group to docker
docker group. For this run following command:
sudo usermod -aG docker $USER
The answer was simple.
docker run -it --privileged --name dcos-ubuntu-python5 python-docker /bin/bash
(This was also mentioned partly in #SunghoMoon's response. So Credits to him).

Docker: error during connect

I am getting the above error whenever i am trying to use RSelenium package
shell('docker run -d -p 4445:4444 selenium/standalone-chrome')
docker: error during connect: Post
http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.30/containers/create: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
See 'docker run --help'.
Warning messages:
1: running command 'C:\Windows\system32\cmd.exe /c docker run -d -p
4445:4444 selenium/standalone-chrome' had status 127
2: In shell("docker run -d -p 4445:4444 selenium/standalone-chrome") :
'docker run -d -p 4445:4444 selenium/standalone-chrome' execution failed with error code 127
Check the stauts of docker environment variables which is not properly set. Kindly, check with the below command,
docker-machine env box
(Note: By default the env set for docker-machine is default)
Otherwise you can set it as like the below
$ set | grep DOCKER
DOCKER_CERT_PATH=C:\Users\mohan\.docker\machine\machines\deis
DOCKER_HOST=tcp://192.168.99.100:2376
DOCKER_MACHINE_NAME=deis
DOCKER_TLS_VERIFY=1
DOCKER_TOOLBOX_INSTALL_PATH=C:\Program Files\Docker Toolbox
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
deis * virtualbox Running tcp://192.168.99.100:2376 v17.03.0-ce
$ docker ps -a
time="2017-03-23T11:11:55-07:00" level=info msg="Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ docker pull busybox
time="2017-03-23T11:13:07-07:00" level=info msg="Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows"
Using default tag: latest
latest: Pulling from library/busybox
7520415ce762: Pull complete
Digest: sha256:32f093055929dbc23dec4d03e09dfe971f5973a9ca5cf059cbfb644c206aa83f
Status: Downloaded newer image for busybox:latest
Hope this will work.

Docker not working after installation

I tried installing the docker using the linux method.
However when the command $docker run hello-world is executed, it outputs:
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
What can be done about this?
First of all make sure the daemon is running:
$ps aux|grep "docker daemon"|grep -v "grep"
A) The daemon is not launched (no lines are returned by the ps)
Start the daemon that is not working:
$sudo /usr/bin/docker daemon -H unix:///var/run/docker.sock
Or start it as a service with:
$sudo /usr/sbin/service docker start
At this point the daemon is launched.
B) The daemon is launched
As shown by the ps with something like:
[..] /usr/bin/docker daemon -H unix:///var/run/docker.sock
You're good to go with your first container with a:
$sudo docker run hello-world.
sudo and docker
If you want to use docker without being sudo (this you should, though you must be aware of the security warning!) a good read of this will help you.
You have to run this command as sudo.
sudo docker run hello-world
This will give you enough privileges to perform that action.
If you want to enable your user to rung docker without sudo, then check out this answer.

How to config docker registry mirror?

I have learn tutorial from that.I have create docker mirror in this command:
docker run -d -p 5555:5000 -e STORAGE_PATH=/mirror -e STANDALONE=false -e MIRROR_SOURCE=https://registry-1.docker.io -e MIRROR_SOURCE_INDEX=https://index.docker.io -v /Users/v11/Documents/docker-mirror:/mirror --restart=always --name mirror registry
And it succeed. Then I start my docker daemon using this command:
docker --insecure-registry 192.168.59.103:5555 --registry-mirror=http://192.168.59.103:5555 -d
Then I use command to pull image like that:
docker pull hello-world
Then it throw error in log, and more detail is:
ERRO[0012] Unable to create endpoint for http://192.168.59.103:5555/:
invalid registry endpoint https://192.168.59.103:5555/v0/: unable to
ping registry endpoint https://192.168.59.103:5555/v0/ v2 ping attempt
failed with error: Get https://192.168.59.103:5555/v2/: EOF v1 ping
attempt failed with error: Get https://192.168.59.103:5555/v1/_ping:
EOF. If this private registry supports only HTTP or HTTPS with an
unknown CA certificate, please add --insecure-registry
192.168.59.103:5555 to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the
flag; simply place the CA certificate at
/etc/docker/certs.d/192.168.59.103:5555/ca.crt
As you can see, it tell me to add '--insecure-registry 192.168.59.103:5555',But I have added it when I start docker daemon. Anyone have idea about it?
You´re probably using boot2docker?
Could you try that:
$ boot2docker init
$ boot2docker up
$ boot2docker ssh "echo $'EXTRA_ARGS=\"--insecure-registry <YOUR INSECURE HOST>\"' | sudo tee -a /var/lib/boot2docker/profile && sudo /etc/init.d/docker restart"
Taken from here

Resources