英文:
Docker - how to set image name
问题
I have docker image which is created with docker-compose. There are 2 containers inside image. I need to change image name from 8_flask_nginx_docker to e.g. jodynek/flask-nginx:0.0.1.RELEASE. Is it possible inside docker-compose.yml? Thanks for help.
docker-compose.yml:
version: '3.9'  
services:
  web-app:
    image: jodynek/flask-nginx:0.0.1.RELEASE
    build: .
    command: python main.py
    volumes:
      - .:/code
    ports:
      - "3000:3000"
  nginx-proxy:
    image: nginx:alpine
    ports:
      - "8888:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    depends_on:
      - web-app
英文:
I have docker image which is created with docker-compose. There are 2 containers inside image. I need to change image name from 8_flask_nginx_docker to e.g. jodynek/flask-nginx:0.0.1.RELEASE. Is it possible inside docker-compose.yml? Thanks for help.
docker-compose.yml:
version: '3.9'  
services:
  web-app:
    image: jodynek/flask-nginx:0.0.1.RELEASE
    build: .
    command: python main.py
    volumes:
      - .:/code
    ports:
      - "3000:3000"
  nginx-proxy:
    image: nginx:alpine
    ports:
      - "8888:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    depends_on:
      - web-app
答案1
得分: 1
- 项目名称是 
my-project-name,你可以使用-p选项进行设置。 - 如果你想设置自定义容器名称:
- web-app 服务的容器名称是 
my-web-container。 - nginx-proxy 服务的容器名称是 
my-proxy。 
 - web-app 服务的容器名称是 
 
英文:
That's the project name and you can set it up with -p option.
docker compose -p my-project-name up.
If you want to set a custom container name:
services:
  web-app:
    container_name: my-web-container // <--- name here
    image: jodynek/flask-nginx:0.0.1.RELEASE
    build: .
    command: python main.py
    volumes:
      - .:/code
    ports:
      - "3000:3000"
  nginx-proxy:
    container_name: my-proxy // <-- name here
    image: nginx:alpine
    ports:
      - "8888:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    depends_on:
      - web-app
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。



评论