Hoà*_*ùng 1 docker docker-compose docker-swarm
我正在尝试使用 docker 堆栈部署应用程序。建立与泊坞窗,撰写(已运行测试后完全确定),我创建了一个群,加入它,并试图逃跑
docker stack deploy --compose-file docker-compose.yml default
Run Code Online (Sandbox Code Playgroud)
出现以下错误:
failed to create service default_sharkcop-api: Error response from daemon: rpc error: code = InvalidArgument desc = ContainerSpec: image reference must be provided
Run Code Online (Sandbox Code Playgroud)
这是我的 docker-compose.yml
version: "3"
services:
# Define the api web application
sharkcop-api:
# Build the Dockerfile that is in the web directory
build:
context: ./sharkcop-api
dockerfile: Dockerfile
# Always restart the container regardless of the exit status; try and restart the container indefinitely
restart: always
# Expose port 8000 to other containers (not to the host of the machine)
expose:
- "8080"
# Link the containers together so they can talk to one another
links:
- redis
# Pass environment variables to the flask container (this debug level lets you see more useful information)
environment:
port: 8080
REDIS_URL: redis://cache
# Deploy with three replicas in the case one of the containers fails (only in Docker Swarm)
deploy:
mode: replicated
replicas: 3
# Define the NGINX forward proxy container
nginx:
# build the nginx Dockerfile
build:
context: ./reverse-proxy
dockerfile: Dockerfile
restart: always
# Expose port 80 to the host machine
ports:
- "80:80"
deploy:
mode: replicated
replicas: 3
# The application needs to be available for NGINX to make successful proxy requests
depends_on:
- sharkcop-api
# Define the sharkcop-webinspector
sharkcop-webinspector:
build:
context: ./sharkcop-webinspector
dockerfile: Dockerfile
restart: always
expose:
- "8080"
# Mount the web directory within the container at /app/sharkcop-webinspector
volumes:
- ./sharkcop-webinspector:/app/sharkcop-webinspector
links:
- sharkcop-api
deploy:
mode: replicated
replicas: 3
redis:
image: redis
container_name: cache
command: ["redis-server", "--appendonly", "yes"]
restart: always
expose:
- 6379
volumes:
- ./data/redis:/data
Run Code Online (Sandbox Code Playgroud)
我正在使用 Docker 版本 19.03.8,构建 afacb8b和 docker -compose 版本 1.25.4,构建 8d51620a
当您docker stack deploy从撰写文件运行时。image从 Dockerfile 构建它时,您还需要提及名称。
请参考以下 docker-compose.yaml
version: "3"
services:
# Define the api web application
sharkcop-api:
# Build the Dockerfile that is in the web directory
image: sharcop-api
build:
context: ./sharkcop-api
dockerfile: Dockerfile
# Always restart the container regardless of the exit status; try and restart the container indefinitely
restart: always
# Expose port 8000 to other containers (not to the host of the machine)
expose:
- "8080"
# Link the containers together so they can talk to one another
links:
- redis
# Pass environment variables to the flask container (this debug level lets you see more useful information)
environment:
port: 8080
REDIS_URL: redis://cache
# Deploy with three replicas in the case one of the containers fails (only in Docker Swarm)
deploy:
mode: replicated
replicas: 3
# Define the NGINX forward proxy container
nginx:
# build the nginx Dockerfile
image: nginx-proxy
build:
context: ./reverse-proxy
dockerfile: Dockerfile
restart: always
# Expose port 80 to the host machine
ports:
- "80:80"
deploy:
mode: replicated
replicas: 3
# The application needs to be available for NGINX to make successful proxy requests
depends_on:
- sharkcop-api
# Define the sharkcop-webinspector
sharkcop-webinspector:
build:
context: ./sharkcop-webinspector
dockerfile: Dockerfile
restart: always
expose:
- "8080"
# Mount the web directory within the container at /app/sharkcop-webinspector
volumes:
- ./sharkcop-webinspector:/app/sharkcop-webinspector
links:
- sharkcop-api
deploy:
mode: replicated
replicas: 3
redis:
image: redis
container_name: cache
command: ["redis-server", "--appendonly", "yes"]
restart: always
expose:
- 6379
volumes:
- ./data/redis:/data
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4668 次 |
| 最近记录: |