When I restart a container with docker-compose up
with an entrypoint it's not stateless, it keep the context of the previous execution of the entrypoint.
docker-compose file:
version: '3.8'
services:
test:
image: debian:buster-slim
entrypoint: ["/entrypoint.sh"]
volumes:
- ./entrypoint.sh:/entrypoint.sh
command: ["echo", "100"]
entrypoint.sh file:
#!/bin/bash
set -e
set -x
mkdir folder
exec "$@"
the first time it log
Creating network "test_compose_entrypoint_default" with the default driver
Creating test_compose_entrypoint_test_1 ... done
Attaching to test_compose_entrypoint_test_1
test_1 | + mkdir folder
test_1 | + exec echo 100
test_1 | 100
if I rerun a docker-compose up
, the second time it log
Starting test_compose_entrypoint_test_1 ... done
Attaching to test_compose_entrypoint_test_1
test_1 | + mkdir folder
test_1 | mkdir: cannot create directory 'folder': File exists
test_compose_entrypoint_test_1 exited with code 1
If I run docker-compose down
and then it work again, but impossible to run two times in a row.
docker-compose restart
docker-compose restart
same problem