【发布时间】:2019-10-22 07:54:03
【问题描述】:
我正在使用 Docker 版本 19.03.3 与 docker swarm 和 docker 注册表。 我想知道如何使用相同的图像但构建不同的版本。
我的 swarm.yml :
version: '3'
services:
db:
image: 127.0.0.1:5000/postgres:11.5
build: docker-compose.d/postgres
environment:
- PG_MAX_WAL_SENDERS=8
- PG_WAL_KEEP_SEGMENTS=8
- PGDATA=/var/lib/postgresql/data/pgdata
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
deploy:
placement:
constraints:
- node.role == manager
db-slave:
build: docker-compose.d/postgres/slave
image: 127.0.0.1:5000/postgres:11.5
environment:
- PGDATA=/var/lib/postgresql/data/pgdata
- REPLICATE_FROM=db
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
deploy:
placement:
constraints:
- node.role == manager
depends_on:
- db
码头图片:
127.0.0.1:5000/postgres 11.5 839a428f8eac 4 days ago 848MB
127.0.0.1:5000/postgres <none> e5636a8fc5f0 4 days ago 848MB
127.0.0.1:5000/postgres <none> 6c1932b5707c 4 days ago 848MB
postgres 11.5 5f1485c70c9a 5 days ago 293MB
registry <none> f32a97de94e1 7 months ago 25.8MB
docker 文件数据库:
FROM postgres:11.5
COPY ./cluster/ /docker-entrypoint-initdb.d/
RUN apt-get update -y
RUN apt-get install postgis -y
docker 文件 db-slave:
FROM postgres:11.5
RUN apt-get update -y
RUN apt-get install postgis iputils-ping -y
COPY setup-replication.sh /docker-entrypoint-initdb.d/
COPY docker-entrypoint.sh /docker-entrypoint.sh
COPY postgres.sql /docker-entrypoint-initdb.d/
RUN chmod +x /docker-entrypoint-initdb.d/setup-replication.sh /docker-entrypoint.sh
他们都从注册表中镜像 postgres:11.5,这会产生问题 因为我确实想在两者上使用 postgres 11.5,但是要使用不同的构建,因为我需要对它们执行不同的构建过程。一个是复制一个文件,另一个不是。(例如) 我该怎么做?
注册表将两个构建保存为一个 postgres:11.5
【问题讨论】:
标签: docker docker-swarm docker-registry docker-swarm-mode