简体   繁体   中英

How to disable docker container restart

Postgres docker is restarting with changed name after stopping it. How to disable restart?
I've tried

docker update --restart=no my-container-ID

but when i stop container its starting again with new Container ID

$docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
53e52dfc9015        postgres:latest     "docker-entrypoint.s…"   5 hours ago         Up 5 hours          5432/tcp            startmarketplace_db.1.o2i5ig3cn0tba5a64r4vkrb8n

$docker stop 53e52dfc9015

$docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
a75d1587c66d        postgres:latest     "docker-entrypoint.s…"   46 seconds ago      Up 39 seconds       5432/tcp            startmarketplace_db.1.5ukdrwdo1bc0tssf4rzdkjrta

Source code of Dockerfile:

FROM php:7.2-apache
RUN apt-get update \
&& apt-get install -y \
    curl git unzip vim \
    libpng-dev libpq-dev \
&& docker-php-ext-install gd pdo pdo_pgsql pgsql
# Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# xDebug
RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=on" >> /usr/local/etc/php/conf.d/xdebug.ini

# PHP
ADD ./php.ini /usr/local/etc/php

# Apache
ADD ./virtualhost.conf /etc/apache2/sites-enabled
RUN a2enmod rewrite
COPY ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

Source code of docker-compose.yml:

version: '3.1'
services:
  web:
    build: ./xxx
    ports:
  - "9001:80"
volumes:
  - ./app/xxx:/var/www/html
environment:
  XDEBUG_CONFIG: >
    remote_host=172.18.0.1
    idekey=xxx
  PHP_IDE_CONFIG: serverName=xxx
links:
  - db
  db:
     image: postgres
     environment: 
      POSTGRES_DB: xxx
      POSTGRES_USER: xxx
      POSTGRES_PASSWORD: xxx
    ports:
      - "5432:5432"

That's running in swarm mode. You need to stop the service or remove the entire stack.

For just the service:

docker service rm startmarketplace_db

For the entire stack:

docker stack rm startmarketplace

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