I have a simple python image in a Dockerfile
:
FROM python:3.8-slim-buster
RUN apt-get -y update
RUN apt-get -y install git
RUN apt-get update \
&& apt-get install gcc -y \
&& apt-get clean
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip install --upgrade pip
RUN pip3 install -r requirements.txt
ENTRYPOINT ["python"]
I ran this once with a docker-compose.yml
file with an restart: unless-stoped
attribute. Now every time I stop the container, It immediately restarts again. It is behaving as restart: always
. Even when I put in restart: no
, stop the container, rebuild and docker run
, the same thing keeps happening`
How can I kill this container once a for all?
More details:
This is the command that is being auto run every time (got this from doing docker inspect --format "$(curl -s https://gist.githubusercontent.com/efrecon/8ce9c75d518b6eb863f667442d7bc679/raw/run.tpl)" <container id>
as suggested here :
docker run \
--name "/src_python_run_b28e47065e14" \
--runtime "runc" \
--volume "/home/dir/src:/app:rw" \
--log-driver "json-file" \
--restart "" \
--network "my-network_default" \
--network-alias "src_python_run_b28e47065e14" \
--network-alias "6116957bb6af" \
--hostname "6116957bb6af" \
--env "PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
--env "LANG=C.UTF-8" \
--env "PYTHON_VERSION=3.8.15" \
--env "PYTHON_PIP_VERSION=22.0.4" \
--env "PYTHON_SETUPTOOLS_VERSION=57.5.0" \
--env "PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/66030fa0332b4914d4c4d089661a0bdeeeb274/public/get-pip.py" \
--label "com.docker.compose.config-hash"="b2a7338a55582eb17895d8b5c2ee820d7c84ed2c900d7d7de0bb1fa787638d" \
--label "com.docker.compose.container-number"="1" \
--label "com.docker.compose.depends_on"="" \
--label "com.docker.compose.image"="sha256:83d2d8f4fc6374f478b982ecc217caf34c58bccf4a497d182a6e1fe35e5e04" \
--label "com.docker.compose.oneoff"="True" \
--label "com.docker.compose.project"="src" \
--label "com.docker.compose.project.config_files"="/home/dir/src/docker-compose.yml" \
--label "com.docker.compose.project.working_dir"="/home/dir/src" \
--label "com.docker.compose.service"="python" \
--label "com.docker.compose.slug"="b28e47065e14275ac786d683ffcc7cc7489e3efef144d45ab9e2ad4bf48023" \
--label "com.docker.compose.version"="2.5.0" \
--attach stdin \
--attach stdout \
--attach stderr \
--interactive \
--entrypoint "python" \
"src_python" \
"-m" "test" "run" "--file" "true"
Interesting update
As a temporary test I deleted docker-compose.yml
and Dockerfile
so I know no container can be restarted.
The strange thing is that, although the container stopped and is not restarting, I can still see it as a process. If I type ps aux | grep docker
, there is
user 2963491 0.0 0.3 728792 24608 ? Rl 17:01 0:00 docker-compose run python -m test run --file true
I tried killing this process but it is not working since its not fixed, the PID is changing meaning process is being stopped and restarted again. Why is this happening?