例:docker-compose.yml的内容如下:
redis:
build: .
ports:
- "6379:6379"
docker-compose up 执行完之后镜像的名字为redis_redis tag为latest 请问如何配置这个镜像的名字和标签呢?
REPOSITORY TAG IMAGE ID CREATED SIZE
redis_redis latest
天蓬老师2017-04-27 09:05:25
docker-compose generates a container based on your original image. What is defined in your yml file is redis. After generation, redis is the alias of this container. You can just use the name redis directly. docker-compose exec redis bash into your redis container.
黄舟2017-04-27 09:05:25
version: '2'
services:
nginx:
image: "${DOCKER_USER}/nginx:1.11"
build:
context: .
dockerfile: Dockerfile-nginx
volumes:
In the above example, you don’t need to write ${DOCKER_USER}, just write nginx:2.11 at the end. The “:” is preceded by the name and followed by Tag.