老师,请教一下,yaml如何与docker-compose.yml配合使用?
我在本地使用docker-compose up --build -d能正常使用,但是编写了yaml后报错
Failed to pull image “potato.api.service”: rpc error: code = Unknown desc = Error response from daemon: pull access denied for potato.api.service, repository does not exist or may require ‘docker login’
NAMESPACE=
LOGGER=true
LOGLEVEL=info
SERVICEDIR=services
TRANSPORTER=TCP
version: "3.3"
services:
api:
build:
context: .
image: potato.api.service
env_file: docker-compose.env
environment:
SERVICES: api
PORT: 8888
labels:
- "traefik.enable=true"
- "traefik.http.routers.api-gw.rule=PathPrefix(`/`)"
- "traefik.http.services.api-gw.loadbalancer.server.port=8888"
networks:
- internal
user:
build:
context: .
image: potato.user.service
env_file: docker-compose.env
environment:
SERVICES: user
networks:
- internal
traefik:
image: traefik:v2.1
command:
- "--api.insecure=true" # Don't do that in production!
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
ports:
- 8888:80
- 4001:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- internal
- default
networks:
internal:
volumes:
data:
#########################################################
# Common Environment variables ConfigMap
#########################################################
apiVersion: v1
kind: ConfigMap
metadata:
name: common-env
data:
NAMESPACE: ""
LOGLEVEL: info
SERVICEDIR: services
---
#########################################################
# Service for Moleculer API Gateway service
#########################################################
apiVersion: v1
kind: Service
metadata:
name: api
spec:
selector:
app: api
ports:
- port: 8888
targetPort: 8888
---
#########################################################
# API Gateway service
#########################################################
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
spec:
selector:
matchLabels:
app: api
replicas: 2
template:
metadata:
labels:
app: api
spec:
containers:
- name: api
image: potato.api.service
envFrom:
- configMapRef:
name: common-env
env:
- name: SERVICES
value: api
---
#########################################################
# user service
#########################################################
apiVersion: apps/v1
kind: Deployment
metadata:
name: user
spec:
selector:
matchLabels:
app: user
replicas: 2
template:
metadata:
labels:
app: user
spec:
containers:
- name: user
image: potato.user.service
envFrom:
- configMapRef:
name: common-env
env:
- name: SERVICES
value: user