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
Related
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.
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.
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
I'm studying the Docker documentation, but I'm having a hard time understanding the concept of creating a container, ssh, and ssh back.
I created a container with
docker run -ti ubuntu /bin/bash
Then, it starts the container and I can run commands. docker ps gives me
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0e37da213a37 ubuntu "/bin/bash" About a minute ago Up About a minute keen_sammet
The issue is after I exit the container I can't ssh back.
I tried docker attach that gives me Error: No such container and I tried docker exec -ti <container>/bin/bash that gives me the same message Error: No such container
How do I run and ssh back to the container?
When you exit the bash process, the container exits (in general, a container will exit when the foreground process exits). The error message you are seeing is accurately describing the situation (the container is no longer running).
If you want to be able to docker exec into a container, you will want to run some sort of persistent command. For example, if you were to run:
docker run -ti -d --name mycontainer ubuntu bash
This would start a "detached" container. That means you've started bash, but it's just hanging around doing nothing. You could use docker exec to start a new process in this container:
$ docker exec -it mycontainer ps -fe
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 16:28 pts/0 00:00:00 bash
root 17 0 0 16:28 pts/1 00:00:00 ps -fe
Or:
$ docker exec -it mycontainer bash
There's really no reason to start bash as the main process in this case, since you're not interacting with it. You can just as easily run...
docker run -ti -d --name mycontainer ubuntu sleep inf
...and the behavior would be the same.
The most common use case for all of this is when your docker run command starts up some sort of persistent service (like a web server, or a database server, etc), and then you use docker exec to perform diagnostic or maintenance tasks.
The docker attach command will re-connect you with the primary console of a detached container. In other words, if we return to the initial example:
docker run -ti -d --name mycontainer ubuntu bash
You could connect to that bash process (instead of starting a new one) by running:
docker attach mycontainer
At this point, exit would cause the container to exit.
First, you don't ssh to a docker container (unless you have a sshd process in that container). But you can execute a command with docker exec -ti mycontainer bash -l
But you can exec a command only on running container. If the container exited already you must use another approach : create an image from the container and run a new one.
Here is an example. First I create a container and create a file within then I exit it.
$ docker run -ti debian:9-slim bash -l
root#09f889e80153:/# echo aaaaaaaaaa > /zzz
root#09f889e80153:/# cat /zzz
aaaaaaaaaa
root#09f889e80153:/# exit
logout
As you can see the container is exited (Exited (0) 24 seconds ago)
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
09f889e80153 debian:9-slim "bash -l" 45 seconds ago Exited (0) 24 seconds ago thirsty_hodgkin
So I create a new image with docker commit
$ docker commit 09f889e80153 bla
sha256:6ceb88470326d2da4741099c144a11a00e7eb1f86310cfa745e8d3441ac9639e
So I can run a new container that contains previous container content.
$ docker run -ti bla bash -l
root#479a0af3d197:/# cat zzz
aaaaaaaaaa
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).