Al docker images exit 126 status - docker

I have just installed Ubuntu 20.0 and installed docker using snap. I'm trying to run some different docker images for hbase and rabbitmq but each time I start an image, it immediately exists with 126 status.
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d58720fce3a dajobe/hbase "/opt/hbase-server" 5 seconds ago Exited (126) 4 seconds ago hbase-docker
b7a84731a05b harisekhon/hbase "/entrypoint.sh" About a minute ago Exited (126) 59 seconds ago optimistic_goldwasser
294b95ef081a harisekhon/hbase "/entrypoint.sh" About a minute ago Exited (126) About a minute ago goofy_tu
I have tried everything and tried to use docker inspect on separate images, but nothing gives away, why the containers exit out immediately. Any suggestions?
EDIT
When i run the command i run the following
$ sudo bash start-hbase.sh
It gives the output exactly like it should
Starting HBase container
Container has ID 3c3e36e1e0fbc59aa0783a4c7f3cb8690781b2d04e8f842749d629a9c25e0604
Updating /etc/hosts to make hbase-docker point to (hbase-docker)
Now connect to hbase at localhost on the standard ports
ZK 2181, Thrift 9090, Master 16000, Region 16020
Or connect to host hbase-docker (in the container) on the same ports
For docker status:
$ id=3c3e36e1e0fbc59aa0783a4c7f3cb8690781b2d04e8f842749d629a9c25e0604
$ docker inspect $id
I think the issue might be due to some permissions, because i tried to chck the logs as suggested in the comments, and get this error:
/bin/bash: /opt/hbase-server: Permission denied

Check if the filesystem is mounted with noexec option using mount command or in /etc/fstab. If yes, remove it and remount the filesystem (or reboot).

Quick solution is restart service docker and network-manager

Related

Can seem to bring down docker containers

I run docker ps and it shows that 5 containers that have been running for three weeks.
I then run docker-compose down but when I run docker ps again, they are all still running.
I have tried the following command but none seems to work
kill
stop
down --rmi local
rm
down
How can I stop these? I tried just bringing up my new docker-compose.yml and ignoring the olde one but I get:
ERROR: for apache Cannot create container for service apache: Conflict. The container name "/apache" is already in use by container "70c570d60e1248292f279a37634fd8b4ce7e2535d2bfa14b2c6e4089652c0152". You have to remove (or rename) that container to be able to reuse that name.
What to try to stop the old container?
You can list containers:
(base) docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c788727f0f7b postgres:14 "docker-entrypoint.s…" 7 days ago Up 7 days 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp dev-db
88e8ddcb7d4e redis "docker-entrypoint.s…" 7 days ago Up 7 days 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp beautiful_neumann
Delete container:
(base) docker rm -f c788727f0f7b # container_id
c788727f0f7b
List containers:
(base) docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
88e8ddcb7d4e redis "docker-entrypoint.s…" 7 days ago Up 7 days 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp beautiful_neumann
As you can see the container got stopped(c788727f0f7b).
You can list stopped containers using:
docker container ls -f 'status=exited'

Can't get my Docker Container to start and give me a shell

I am trying to get a Docker Container running. I am following this guide: http://opendata.cern.ch/docs/cms-guide-docker.
The container refuses to start and give me access to the shall I expect.
Running the following command (as mentioned in the guide) does nothing, the process exits with a non-0 exit code. The first time I ran it, it downloaded the container image but did not land me into the sell as the guide says it would.
$ docker run --name opendata-2010 -it cmsopendata/cmssw_4_2_8 /bin/bash
I can see the container, it exits soon as it starts.
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
be670158d200 cmsopendata/cmssw_5_3_32 "/opt/cms/entrypoint…" 34 minutes ago Exited (139) 3 seconds ago opendata
These are other things I have tried to no avail.
$ docker exec -it be670158d200 /bin/bash
Error response from daemon: Container be670158d200ae85871fbda810fa6074dcb7bc8fc606f000710f630add1b80b6 is not running
$ docker start --attach be670158d200
failed to resize tty, using default size
My question is similar to this: Docker - Container is not running, but I know that unlike in that question, here I should be getting the shell.
I am running this in Windows Subsystem for Linux 2 - Ubuntu 20.04, docker version 19.03.8 - build afacb8b7f0. Any help is greatly appreciated, thanks.
I had the same error with below logs
dockerd[15309]: time="2022-01-11T11:13:35.133154132+05:30" level=error msg="Handler for POST /v1.41/exec/94553dc2f9aaa3c1245df7384138786a8a576af99105a285258fce8b980b4660/resize returned error: timeout waiting for exec session ready"
This is a bug in docker 20.10 version and can be solved by downgrading containerd rpm
Removed:
containerd.io.x86_64 0:1.4.4-3.1.el7
Installed:
containerd.io.x86_64 0:1.4.3-3.1.el7

Docker-compose restart:unless stopped - strange behavior

> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
210ebea2ef5f localhost.localdomain/foo "node app.js -C conf…" 12 minutes ago Restarting (1) 9 minutes ago foo
> docker stop 210ebea2ef5f
210ebea2ef5f
> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
210ebea2ef5f localhost.localdomain/foo "node app.js -C conf…" 12 minutes ago Restarting (1) 9 minutes ago foo
huh?
> docker kill 210ebea2ef5f
Error response from daemon: Cannot kill container: 210ebea2ef5f: Container 210ebea2ef5f6f25265a3da88954fe111fabba99602ef628e0ee88630e26fd5d is not running
> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
210ebea2ef5f localhost.localdomain/foo "node app.js -C conf…" 12 minutes ago Restarting (1) 9 minutes ago foo
has anybody some enlightenment on what's going on here? I've started noticing this once I've enabled restart policies on my containers. This is running in docker for windows (18.09.3). The restart policy is set using docker compose as follows:
version: '3'
services:
foo:
build: .
image: localhost.localdomain/${repository_name}
container_name: ${container_name}
restart: unless-stopped:0
Are restart policies just buggy in docker for windows?
btw. a docker rm 210ebea2ef5f did finally remove the container from my docker ps list, but that's not the behavior I'd expect.
This looks like a bug with docker ps that is being fixed in 18.09.5. If you inspect the container with:
docker inspect 210ebea2ef5f --format '{{ json .State }}'
the status should show as exited.
The reason I suspect you're seeing this bug with docker ps is because the status shows 9 minutes ago where a normal crash loop happens in seconds. You can try the rc1 for 18.09.5 that was just pushed (this requires that you are pulling updates from the testing release), or wait for the final 18.09.5 to be released and update to that. It appears to only be an issue with the ps output, and have no effect on the behavior of the containers themselves.
Your restart policy is doing exactly what you've asked it to do.
If you look at the STATUS column in the output of docker ps, you see:
Restarting (1) 9 minutes ago
This typically means that the container is not running successfully: it starts, then exits immediately, and is then immediately restarted by Docker. This means that there are good odds that when you run docker kill, the container is in fact not running.
You could run docker stop <id> to stop the container and prevent it from restarting.
You would need to investigate your logs and your Dockerfile to determine why the container is exiting in the first place.

Ensuring Docker container will start automatically when host starts

Is there a way to start a Docker container automatically when the host starts? Before, I use the ‘—restart always’ parameter with docker run but it only works if Docker Engine is not killed.
As your comment, I think you have misunderstood about --restart always.
Once docker run --restart always container is run, the container is restarted every time the host is restarted even though you stop the container explicitly .
For example.
$ docker run --restart always --detach --name auto-start-redis redis
d04dfbd73eb9d2ba5beac41363aa5c45c0e034e08173daa6146c3c704e0cd1da
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d04dfbd73eb9 redis "docker-entrypoint..." 4 seconds ago Up 4 seconds 6379/tcp auto-start-redis
$ reboot
# After reboot-------------------------------
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d04dfbd73eb9 redis "docker-entrypoint..." About a minute ago Up 21 seconds 6379/tcp auto-start-redis
$ docker stop auto-start-redis
auto-start-redis
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d04dfbd73eb9 redis "docker-entrypoint..." 2 minutes ago Exited (0) 30 seconds ago auto-start-redis
$ reboot
# After reboot-------------------------------
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d04dfbd73eb9 redis "docker-entrypoint..." 3 minutes ago Up 12 seconds 6379/tcp auto-start-redis
However, of course, it is based upon a premise that docker-host is auto-started. docker-host in here means docker daemon process itself. Usually docker-host will auto-start by default but if it is not, you need to set it yourself.
I am not sure which OS you are using but when it comes to Ubuntu16, you can make it with systemctl command.
$ sudo systemctl enable docker
# To tell systemd to start services automatically at boot, you must enable.
If you use docker swarm, you can make global service with --mode global flag that ensures run on every node in docker swarm.
docker service create --mode global ...
If you don't use docker swarm, the best solution I think is to use init system of your system like systemd as #I.R.R said. You can make your own service file for systemd and specify the condition when the service starts like below.
[Unit]
Description=Your App
After=docker
Refer to this article by digital ocean.

docker logs <C> returns nothing

I build and run a docker image with
docker run --detach --name api rkevinburton/myagsourceapi
But when I 'docker ps -a' I get a message that this container has exited.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ee956fbf1d7f rkevinburton/myagsourceapi "/bin/bash" 10 seconds ago Exited (0) 8 seconds ago api
So I want to find out why it exited. So I issue the command
docker logs ee
But this command returns nothing. As the docker host is a Windows machine I looked on ~\AppData\Local\Docker but the information in the log*.txt or install-log.* didn't seem to help me any. How can I get more information on why the container 'Exited'?
Docker containers exit when their main process finishes. That is why you don't get any logs.
The docker logs command batch-retrieves logs present at the time of execution.
(see: https://docs.docker.com/engine/reference/commandline/logs/)
An example:
The following will create a new container and start it:
docker run -d --name=my_test_container alpine ping -c 20 127.0.0.1
[----run----] [--------name--------] [image][-----command------]
Try to use the following, before ping command stops:
docker logs my_test_container
docker logs --follow my_test_container
The first one shows what has been printed out by ping (until then) and the second one gives you logs as ping prints out new lines.
After 20 ping requests, the ping command finishes and the container stops.
ubuntu#ubuntu:~$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e8f371000146 alpine "ping -c 20 127.0.0.1" 29 seconds ago Exited (0) 9 seconds ago my_test_container

Resources