I am trying to start archlinux image and later add volumes so I can test my scripts on configuring Arch Linux. But I am stuck with starting the compose. If I have restart: always it just restarts all the time when I comment it out, then it gives me the exited with code 0.
version: "3.7"
services:
arch:
image: archlinux/base
# restart: always
I start compose with
$docker-compose up
and the output is
Creating network "docker-compose_default" with the default driver
Creating docker-compose_arch_1 ... done
Attaching to docker-compose_arch_1
docker-compose_arch_1 exited with code 0
What might be missing?
Any help is much appreciated. I have being stuck with this problem for quite a while.
The base image you are using at the moment executes /usr/bin/bash
as a default command which requires allocation of a tty to keep running (or you will have to change the command to any long running task).
See what happens with docker itself in first place.
Starting a container interactively works as expected:
$ docker run -it --rm archlinux/base
[root@6642c519e328 /]# more /etc/issue
Arch Linux \r (\l)
[root@6642c519e328 /]# exit
Now let's try to run a container in the background:
$ docker run -d --name testarch archlinux/base
915ff11b0c93bd795eb62d37cd2d9928638560d9accfb2e5ba061b3ef19c0235
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ # Hoho, it's not running
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
915ff11b0c93 archlinux/base "/usr/bin/bash" 8 seconds ago Exited (0) 7 seconds ago testarch
$ docker rm testarch
testarch
If we do the same with a tty allocation:
$ docker run -d --tty --name testarch archlinux/base
d160a3d7e18c3d094f47577b448a11808eb30ce7ba8fad4cde882818f248f207
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d160a3d7e18c archlinux/base "/usr/bin/bash" 5 seconds ago Up 4 seconds testarch
$ # Tada ! It runs, we can now attach to it.
$ docker exec -it testarch bash
[root@d160a3d7e18c /]# more /etc/issue
Arch Linux \r (\l)
[root@d160a3d7e18c /]# exit
$ docker rm -f testarch
Now back to your docker-compose.yml
. In your current test phase, you need to allocate a tty (that you will be able to drop later if you cmd/entry-point does not require one anymore).
version: "3.7"
services:
arch:
image: archlinux/base
tty: true
For time being, the bash command is not sending anything in the container log. I will start in detached mode so the command returns once the container is started and I can use the same terminal (launch a second terminal if you still want to to run docker-compose in foreground mode)
$ pwd
/tmp/slack_test
$ docker-compose up -d
Creating network "slack_test_default" with the default driver
Creating slack_test_arch_1 ... done
$ docker-compose exec arch bash
[root@10f138d98782 /]# more /etc/issue
Arch Linux \r (\l)
[root@10f138d98782 /]# exit
exit
$ docker-compose down
Stopping slack_test_arch_1 ... done
Removing slack_test_arch_1 ... done
Removing network slack_test_default
$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With