intermediate/workshop/DockerCompose/images_command.md
The docker-compose images command help to listout images used/created by the containers.
$ mkdir -p docker-compose/build
$ cd docker-compose/build
FROM nginx:alpine
RUN echo "Welcome to Docker Workshop!" >/usr/share/nginx/html/index.html
CMD ["nginx", "-g", "daemon off;"]
version: "3.7"
services:
webserver:
build:
context: .
dockerfile: Dockerfile
image: webapp:v1
container_name: Nginx
ports:
- "80:80"
dbserver:
image: mysql:5.7
container_name: Mysqldb
restart: unless-stopped
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: Pa$$w0rd
MYSQL_USER: test
MYSQL_PASSWORD: Pa$$w0rd123
MYSQL_DATABASE: test
volumes:
- db_data:/var/lib/mysql
volumes:
db_data:
$ docker-compose up -d
NOTE: This will build the images and bringup the containers. <b>-d</b> option which will run the container in background.
$ docker-compose images
Container Repository Tag Image Id Size
-----------------------------------------------------
Mysqldb mysql 5.7 383867b75fd2 356 MB
Nginx webapp v1 3454fa918c0d 20.2 MB
mysql is the one used for dbserver and <b>webapp:v1</b> is the custome image used for webserver.
Next » Lab #9: ps Command