简体   繁体   English

用新镜像重启 Docker 容器

[英]Restart Docker Container with new Image

One of my Docker Containers can update itself (talking to the Docker Daemon using the Spotify Docker Client).我的 Docker 容器之一可以自行更新(使用 Spotify Docker 客户端与 Docker 守护程序对话)。 After downloading the new image a container restart is required, with the new iamge of course.下载新映像后,需要重新启动容器,当然要使用新的 iamge。

If I just kill the running process inside the container, Docker restarts it using the old image.如果我只是杀死容器内正在运行的进程,Docker 会使用旧映像重新启动它。 Is there any reliable way to force recreating the container using the new image?是否有任何可靠的方法可以强制使用新图像重新创建容器? Couldn't find anything in the docker-compose docs.在 docker-compose 文档中找不到任何内容。 It's a single host environment only, no Kubernetes or something like that in use.它只是一个单一的主机环境,没有 Kubernetes 或类似的东西在使用。

Compose file snippet:编写文件片段:

  dockerctl:
    image: myimage
    container_name: dockerctl
    networks:
      - mynetwork
    ports:
      - "8099:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    restart: always

Bit of an old question, but this should do it: Update the image name in your docker-compose.yml and restart it by running docker-compose up -d --no-deps dockerctl .有点老问题,但应该这样做:更新 docker-compose.yml 中的图像名称并通过运行docker-compose up -d --no-deps dockerctl重新启动它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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