Lab #8: images Command

The docker-compose images command help to listout images used/created by the containers.

Pre-requisite:

Tested Infrastructure

Platform Number of Instance Reading Time
Play with Docker 1 5 min

Pre-requisite

Assignment

Create a docker-compose.yml with custom image

Setup environment

$ mkdir -p docker-compose/build $ cd docker-compose/build 

Now lets create the Dockerfile

FROM nginx:alpine RUN echo "Welcome to Docker Workshop!" >/usr/share/nginx/html/index.html CMD ["nginx", "-g", "daemon off;"] 

Create a docker-compose.yml file

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: 

Bringup the containers

$ docker-compose up -d 

NOTE: This will build the images and bringup the containers. -d option which will run the container in background.

List out the images used by the containers

$ 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 webapp:v1 is the custome image used for webserver.

Contributor

Savio Mathew

Next ยป Lab #9: ps Command