如何禁用docker容器重启

时间:2018-05-15 14:25:52

标签: postgresql docker

Postgres docker在停止后重新启动并更改了名称。 如何禁用重启?
我试过了

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

但是当我停止容器时,它会再次启动新的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

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"]

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"

1 个答案:

答案 0 :(得分:0)

那是在群集模式下运行的。您需要停止服务或删除整个堆栈。

仅用于服务:

docker service rm startmarketplace_db

对于整个堆栈:

docker stack rm startmarketplace