Docker: error during connect - docker

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.

Related

docker service shows an image running but not listed in docker container

I created a service such like
$ docker service create --name psql --secret psql_user --secret psql_pass -e POSTGRES_PASSWORD_FILE=/run/secrets/psql_pass -e POSTGRES_USER_FILE=/run/secrets/psql_user postgres
n48qvp8ulvvk5tp8vwaj7q8fo
overall progress: 1 out of 1 tasks
1/1: running [==================================================>]
verify: Service converged
$ docker service ps psql
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
v3tnzutt0akj psql.1 postgres:latest node2 Running Running 3 minutes ago
However, docker container didn't show any image running and unable to exec:
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ docker exec -it psql bash
Error: No such container: psql
Session info:
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
$ docker --version
Docker version 19.03.11, build 42e35e61f3
Have I missed something?
It looks like the container is crashing on initial boot. Can you start it with the the flag:
--restart always
And then post output of docker container ls? I suspect it will show up, but be in a state of constant reboot.

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: user namespace remapping not working although enabled for daemon

Processes in docker containers are still running under the "host's" UID although I have enabled user namespace remapping.
OS is: Ubuntu 16.04 on 4.4.0-21 with
> sudo docker --version
Docker version 1.12.0, build 8eab29e
dockerd configuration is
> grep "DOCKER_OPTS" /etc/default/docker
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 --ipv6 --userns-remap=default"
subordinate UID and GID mappings have been created, when I had run manually, i.e., with the above docker opts string
> grep "dock" /etc/sub*
/etc/subgid:dockremap:362144:65536
/etc/subuid:dockremap:362144:65536
However, the sub UID/GIDs got not created when I (re)started dockerd as service - but had to run it manually.
Also after restarting dockerd, all processes in containers are not in the remapped range but 1to1 that of the host, i.e., a container root process still has UID=0.
E.g., a test container running just top
> sudo docker run -t -i ubuntu /usr/bin/top
...
has top run by UID=0 when checked outside the container on the host
> ps -xaf --forest -o pid,ruid,ruser,cmd | grep top
PID RUID RUSER CMD
23015 0 root | \_ sudo docker run -t -i ubuntu /usr/bin/top
23016 0 root | \_ docker run -t -i ubuntu /usr/bin/top
Apparently, the remapping to subordinate UIDs is not working for me when running docker as a daemon?
/etc/default/docker is not used when running the dockerd via systemd.
Thus any changes I did on the docker-config (after the dist-upgrade I had applied before) where not applied.
For configuring the docker daemon with Systemd see the documantation at
https://docs.docker.com/engine/admin/systemd/
with the configuration drop-in file(s) going to
/etc/systemd/system/docker.service.d

Can not pull docker image

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).

docker error: /var/run/docker.sock: no such file or directory

I am new to docker. I have a shell script that loads data into impala and I want a docker file that runs builds an image and run the container.
I am on mac, installed boot2docker and have the DOCKER_HOST env set up.
bash-3.2$ docker info
Containers: 0
Images: 0
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Dirs: 0
Execution Driver: native-0.2
Kernel Version: 3.15.3-tinycore64
Debug mode (server): true
Debug mode (client): false
Fds: 10
Goroutines: 10
EventsListeners: 0
Init Path: /usr/local/bin/docker
Sockets: [unix:///var/run/docker.sock tcp://0.0.0.0:2375]
I am trying to just installed a pre-built image using:
sudo docker pull busybox
I get this error:
sudo docker pull busybox
2014/08/18 17:56:19 Post http:///var/run/docker.sock/images/create?fromImage=busybox&tag=: dial unix /var/run/docker.sock: no such file or directory
Is something wrong with my docker setup?
When I do a docker pull busybox, It pulls the image and download is complete.
bash-3.2$ docker pull busybox
Pulling repository busybox
a9eb17255234: Download complete
fd5373b3d938: Download complete
d200959a3e91: Download complete
37fca75d01ff: Download complete
511136ea3c5a: Download complete
42eed7f1bf2a: Download complete
c120b7cab0b0: Download complete
f06b02872d52: Download complete
120e218dd395: Download complete
1f5049b3536e: Download complete
bash-3.2$ docker run busybox /bin/echo Hello Doctor
Hello Doctor
Am I missing something?
You don't need to run any docker commands as sudo when you're using boot2docker as every command passed into the boot2docker VM runs as root by default.
You're seeing the error when you're running as sudo because sudo doesn't have the DOCKER_HOST env set, only your user does.
You can confirm this by doing a:
$ env
Then a
$ sudo env
And looking for DOCKER_HOST in each output.
As for having a docker file that runs your script, something like this might work for you:
Dockerfile
FROM busybox
# Copy your script into the docker image
ADD /path/to/your/script.sh /usr/local/bin/script.sh
# Run your script
CMD /usr/local/bin/script.sh
Then you can run:
docker build -t your-image-name:your-tag .
This will build your docker image, which you can see by doing a:
docker images
Then, to run your container, you can do a:
docker run your-image-name:your-tag
This run command will start a container from the image you created with your Dockerfile and your build command and then it will finish once your script.sh has finished executing.
You can quickly setup your environment using shellinit
At your command prompt execute:
$(boot2docker shellinit)
That will populate and export the environment variables and initialize other features.
docker pull will fail if docker service is not running. Make sure it is running by
:~$ ps aux | grep docker
root 18745 1.7 0.9 284104 13976 ? Ssl 21:19 0:01 /usr/bin/docker -d
If it is not running, you can start it by
sudo service docker start
For Ubuntu 15 and above use
sudo systemctl start docker
On my MAC when I start boot2docker-vm on the terminal using
boot2docker start
I see the following
To connect the Docker client to the Docker daemon, please set:
export DOCKER_CERT_PATH=<my things>
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://<ip>:2376
After setting these environment variables I was able to run the build without the problem.
Update [2016-04-28] If you are using a the recent versions of docker you can do
eval $(docker-machine env) will set the environment
(docker-machine env will print the export statements)
I also got this error. Though, I did not use boot2docker but just installed "plain" docker on Ubuntu (see https://docs.docker.com/installation/ubuntulinux/).
I got the error ("dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?") because the docker daemon was not running, yet.
On Ubuntu, you need to start the service:
sudo service docker start
See also http://blog.arungupta.me/resolve-dial-unix-docker-sock-error-techtip64
For boot2docker on Windows, after seeing:
FATA[0000] Get http:///var/run/docker.sock/v1.18/version:
dial unix /var/run/docker.sock: no such file or directory.
Are you trying to connect to a TLS-enabled daemon without TLS?
All I did was:
boot2docker start
boot2docker shellinit
That generated:
export DOCKER_CERT_PATH=C:\Users\vonc\.boot2docker\certs\boot2docker-vm
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://192.168.59.103:2376
Finally:
boot2docker ssh
And docker works again
In Linux, first of all execute sudo service docker start in terminal.
If you're using CentOS 7, and you've installed Docker via yum, don't forget to run:
$ sudo systemctl start docker
$ sudo systemctl enable docker
This will start the server, as well as re-start it automatically on boot.
To setup your environment and to keep it for the future sessions you can do:
echo 'export DOCKER_HOST="tcp://$(boot2docker ip 2>/dev/null):2375";' >> ~/.bashrc
Then:
source ~/.bashrc
And your environment will be setup in every session
The first /var/run/docker.sock refers to the same path in your boot2docker virtual machine. Correcly write for windows /var/run/docker.sock
You, maybe the not the OP, but someone may have a directory called /var/run/docker.sock/ already due to how many times you hack and slash to get things right with docker (especially noobs). Delete that directory and try again.
This helped me on my way to getting it to work on Centos 7.
I have installed the docker using offline method and post server restart docker is not running.
So, I executed the below command it worked for me!
/usr/bin/dockerd > /dev/null
run the following commands, OS = CentOS / RHLE / Amazon Linux, etc.
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker
chmod 777 /var/run/docker.sock

Resources