docker-compose can't connect to docker daemon? - docker

I am trying to build a docker environment through docker-compose, however it gives errors.
$ docker-compose build
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
Docker daemon is running
$ sudo systemctl status docker
[sudo] password for mansop:
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-02-19 12:07:27 AEDT; 22min ago
Docs: http://docs.docker.com
Main PID: 8972 (dockerd-current)
Tasks: 22
Memory: 22.8M
CGroup: /system.slice/docker.service
├─8972 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/l...
└─8978 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containe...
Docker installed from centos7 repository:
$ docker --version
Docker version 1.13.1, build 4ef4b30/1.13.1
I tried setting up DOCKER_HOST following the error message but the issue persists:
$ echo $DOCKER_HOST
127.0.0.1:2375
Any thoughts?

For some reason there were no docker group in my system, my user was not part of docker group and the docker socket file was not under the docker group.
The commands below fixed my issue:
sudo useradd docker
usermod aG docker mansop
sudo chown root:docker /var/run/docker.sock

Related

Docker not running Ubuntu 20.04

I've installed docker on a fresh machine and used the following tutorial https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04
I have the following output.
~/code » sudo systemctl status docker ben#bagley
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-08-10 10:36:50 BST; 3s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 19143 (dockerd)
Tasks: 20
Memory: 28.3M
CGroup: /system.slice/docker.service
└─19143 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
However, when I run
curl -s "https://laravel.build/example-app?with=mysql,redis" | bash
I get the following: Docker is not running.
You use sudo systemctl status docker to confirm docker is running, means you are not in root I guess.
And if you execute curl -s "https://laravel.build/example-app?with=mysql,redis" directly, you could see next:
docker info > /dev/null 2>&1
# Ensure that Docker is running...
if [ $? -ne 0 ]; then
echo "Docker is not running."
exit 1
fi
......
Means the curl will download a script, and the log Docker is not running. is print due to not execute docker info correctly when execute that script.
As you are not root, so defintely the docker info could not be run. You have next 3 options to choose to make it work:
Option 1:
sudo usermod -aG docker ${USER} to add current user to docker group, then exit current shell, login the shell again to run the curl command with root.
Option 2:
curl -s "https://laravel.build/example-app?with=mysql,redis" | sudo bash
Option 3:
sudo -s -H to switch to root, then execute the curl command.

ubuntu 20.04 docker consul image - exited state

followed: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04 (those steps always worked for lower version of ubuntu)
docker run -d --name=local-consul -p 8500:8500 -e CONSUL_BIND_INTERFACE=eth0 consul docker
(as I always do)
docker ps
empty
docker ps -a
status: "Exited (0) 4 seconds ago"
docker logs consul-local
==> Found address '172.17.0.2' for interface 'eth0', setting bind option...
/usr/local/bin/docker-entrypoint.sh: exec: line 98: docker: not found
docker --version
Docker version 19.03.11, build 42e35e61f3
systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-06-01 14:30:59 EDT; 22min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 46472 (dockerd)
Tasks: 56
Memory: 194.9M
CGroup: /system.slice/docker.service
└─46472 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Question:
How to fix /usr/local/bin/docker-entrypoint.sh: exec: line 98: docker: not found
I've checked. I do not have this file on my local machine: /usr/local/bin/docker-entrypoint.sh
-d tells Docker to detach and the run the container in the background. It has nothing to do with when the container exits. The container will exit when the entrypoint process terminates. In this case, the hello-world container just prints a message and exits, so it will not continue running, detached or not.
Edit:
docker run -d --name=local-consul -p 8500:8500 -e CONSUL_BIND_INTERFACE=eth0 consul docker
If you look at the entrypoint script for the consul image, you'll see it runs exec "$#". So the docker run command above will attempt to run docker within the consul container. That command doesn't exist in the container, so you get docker: not found.
You likely just want to run the container without additional arguments:
docker run -d --name=local-consul -p 8500:8500 -e CONSUL_BIND_INTERFACE=eth0 consul
See https://hub.docker.com/_/consul

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.

Unable to start Docker service with error "Failed to start docker.service: Unit not found."

I have installed Docker with yum install docker:
$ uname -a
Linux caspgval4 3.10.0-229.20.1.el7.x86_64 #1 SMP Wed Nov 4 10:08:36 CST 2015 x86_64 x86_64 x86_64 GNU/Linux
$ docker --version
Docker version 1.12.6, build 3a094bd/1.12.6
$ docker info
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Docs: http://docs.docker.com
I am trying to install and run Docker, but it is giving an error as below:
$ sudo service docker start
Redirecting to /bin/systemctl start docker.service
Failed to start docker.service: Unit not found.
How do I resolve this issue? I tried the following commands, but no luck:
$ sudo systemctl start docker
Failed to start docker.service: Unit not found.
Extra information:
$ journalctl -u docker
No journal files were found.
-- No entries --
$ cat /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target
Wants=docker-storage-setup.service
Requires=rhel-push-plugin.socket
Requires=docker-cleanup.timer
[Service]
Type=notify
NotifyAccess=all
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd-current \
--add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
--default-runtime=docker-runc \
--authorization-plugin=rhel-push-plugin \
--exec-opt native.cgroupdriver=systemd \
--userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$ADD_REGISTRY \
$BLOCK_REGISTRY \
$INSECURE_REGISTRY
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
MountFlags=slave
[Install]
WantedBy=multi-user.target
I tried the following:
$ sudo systemctl daemon-reload
$ sudo systemctl start docker
Failed to start docker.service: Unit not found.
$ sudo journalctl -u docker
-- No entries --
More debug information:
$ sudo systemctl status network.target
● network.target - Network
Loaded: loaded (/usr/lib/systemd/system/network.target; static; vendor preset: disabled)
Active: active since Mon 2017-01-23 02:54:39 PST; 2 months 29 days ago
Docs: man:systemd.special(7)
http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget
Jan 23 02:54:39 mymachine systemd[1]: Starting Network.
Jan 23 02:54:39 mymachine systemd[1]: Reached target Network.
$ sudo systemctl status docker-storage-setup.service
● docker-storage-setup.service - Docker Storage Setup
Loaded: loaded (/usr/lib/systemd/system/docker-storage-setup.service; disabled; vendor preset: disabled)
Active: inactive (dead)
$ sudo systemctl status rhel-push-plugin.socket
Unit rhel-push-plugin.socket could not be found.
$ sudo systemctl status docker-cleanup.timer
● docker-cleanup.timer - Run docker-cleanup every hour
Loaded: loaded (/usr/lib/systemd/system/docker-cleanup.timer; disabled; vendor preset: disabled)
Active: inactive (dead)
In case someone has installed docker using snap, they can start the service using
sudo snap status docker #check the status
sudo snap start docker # start the service
Run this command to list all the services:
sudo systemctl list-units --type=service
Look for the correct Docker service name (in my case it is snap.docker.dockerd.service) then run:
sudo systemctl restart snap.docker.dockerd.service
It looks like you're missing the rhel-push-plugin.socket unit which is presumably part of a rhel-push-plugin package. You can try fixing that install, or you can install the upstream Docker package directly from Docker with the following as root:
curl -sSL https://get.docker.com/ | sh
Or more appropriately following the CentOS install guide from Docker. (The CentOS install tends to work on even a RHEL system when you have a supported version, which until the recent 20.10 release did not include CentOS 8 or RHEL 8.)
The upstream Docker install will be a more recent version of Docker, but it will not have the various RHEL modifications like the rhel-push-plugin.
Use the following command if your OS is Ubuntu, it will install Docker successfully:
apt install docker.io
if you have installed docker with snap you can check the status of the daemon like this:
sudo snap services docker
If the current column shows inactive then it's not running. Try starting it with this:
sudo snap start docker
Check the service again, if it's still not running after that you can check the logs:
sudo snap logs docker
which might give more hints on what's stopping it from running
For me, I had an error saying that docker could not create a symlink in /etc/docker/ because another file was in the way. Emptying the directory was not enough due to a known bug in the docker snap. The work-around was to delete the directory then refresh the snap (see https://forum.snapcraft.io/t/layouts-still-brittle-when-refreshing-snaps/26252/2)
sudo rm -rf /etc/docker
sudo snap refresh
I worked around the issue by simply doing the following:
$ sudo apt-get purge containerd.io docker-ce
$ rm -rf /var/lib/containerd
[reboot]
$ sudo apt-get install containerd.io docker-ce
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html
Note
In some cases, you may need to reboot your instance to provide permissions for the ec2-user to access the Docker daemon. Try rebooting your instance if you see the following error:
Try installing Docker as root (sudo):
sudo yum install docker
See Installation on Red Hat Enterprise Linux.

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

Resources