gpt4 book ai didi

python - 如何停止Docker数据库容器

转载 作者:行者123 更新时间:2023-12-02 21:02:17 25 4
gpt4 key购买 nike

尝试运行以下docker compose文件

version: '3'

services:
database:
image: postgres
container_name: pg_container
environment:
POSTGRES_USER: partman
POSTGRES_PASSWORD: partman
POSTGRES_DB: partman


app:
build: .
container_name: partman_container
links:
- database
environment:
- DB_NAME=partman
- DB_USER=partman
- DB_PASSWORD=partman
- DB_HOST=database
- DB_PORT=5432
- SECRET_KEY='=321t+92_)@%_4b+f-&0ym(fs2p5-0-_nz5mhb_cak9zlo!bv@'
depends_on:
- database

expose:
- "8000"
- "8020"

ports:
- "127.0.0.1:8020:8020"

volumes:
pgdata: {}

使用以下docker文件运行docker-compose up-build时
# Dockerfile

# FROM directive instructing base image to build upon
FROM python:3.7-buster


RUN apt-get update && apt-get install nginx vim -y --no-install-recommends
COPY nginx.default /etc/nginx/sites-available/default
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log


RUN mkdir .pip_cache \
mkdir -p /opt/app \
mkdir -p /opt/app/pip_cache \
mkdir -p /opt/app/py-partman

COPY start-server.sh /opt/app/
COPY requirements.txt start-server.sh /opt/app/
COPY .pip_cache /opt/app/pip_cache/
COPY partman /opt/app/py-partman/

WORKDIR /opt/app
RUN pip install -r requirements.txt --cache-dir /opt/app/pip_cache
RUN chown -R www-data:www-data /opt/app
RUN /bin/bash -c 'ls -la; chmod +x /opt/app/start-server.sh; ls -la'

EXPOSE 8020
STOPSIGNAL SIGTERM

CMD ["/opt/app/start-server.sh"]


/opt/app/start-server.sh:
#!/usr/bin/env bash
# start-server.sh
ls
pwd

cd py-partman
ls
pwd
python manage.py createsuperuser --no-input
python manage.py makemigrations
python manage.py migrate
python manage.py initialize_entities

数据库镜像继续运行,我想停止它,因为否则jenkins作业将继续等待镜像终止。

任何好的想法/更好的想法怎么做?

最佳答案

也许使用-> docker stop <“容器ID或容器名称”>

如果无法停止,请使用-f强制执行。
尝试一下。

关于python - 如何停止Docker数据库容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60037326/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com