简体   繁体   中英

Docker swarm did not update service

I use docker stack deploy deploy my python service.

First, I edit code.

then

docker build . -f Dockerfile -t my_service:$TAG docker build . -f Dockerfile -t my_service:$TAG docker tag my_service:$TAG register.xxx.com:5000/my_service:$TAG

When I use docker run -p 9000:9000 register.xxx.com:5000/my_service:$TAG

It's worked.

But, when I use docker stack deploy -c docker-compose.yml my_service_stack

The service still is running old code.

The part of docker-compose.yaml:

web: image: register.xxx.com:5000/my_service:v0.0.12 depends_on: - redis - db - rabbit links: - redis - db - rabbit volumes: - web_service_data:/home networks: - webnet

v0.0.12 == $TAG

Dockerfile:

```

FROM python:3.6.4

RUN useradd -ms /bin/bash gmt

RUN mkdir -p /home/logs

WORKDIR /home/gmt/src

COPY /src/requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/

COPY /src .

RUN cat /home/gmt/src/setting/env.yaml

ENV PYTHONPATH=/home/gmt/src

CMD ["gunicorn", "-c", "/home/gmt/src/gunicornconf.py", "run:app"]

```

So, why?

  1. I don't see that you actually pushed your image from your build server to your registry. I'll assume you're doing that after build and before deploy.

  2. You should not be using a volume for code. That volume will overwrite your /home in the container with the contents of the volume, which are likely stale. Using/storing code in volumes is an anti-pattern.

  3. You don't need links: , they are legacy .

  4. depends_on: is not used in swarm.

  5. You should not store logs in the container, you should have them sent to stdout and stderr .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM