Docker

Introduction

Docker is one of the most common software platforms used to create and run containers.

Do Not Use Docker If

Commands

Container Management

Container Inspection

Interacting with Container

Image Management

Image Transfer

Builder

Docker-Compose

The docker-compose utility is used to manage multiple containers together. Very often we need to run multiple containers together to make an application work. And they need very specific configurations to work together, especially in terms of file systems and networking.

The docker-compose.yml file is used to configure the containers. As the .yml extension suggests, it is written in YAML format.

All services are defined in the docker-compose.yml file as named dictionaries. Then each keyed service can have many different kinds of docker configurations. image, is the only required configuration and it's the docker image of that service. Other common configuration keys are build, command, environment, ports and more.

Example

version: '3.4'
services:
expressrestaurantswagger:
image: jrwtango/expressrestaurantswagger
build:
context: .
dockerfile: ./Dockerfile
environment:
NODE_ENV: development
ports:
- "3000:3000"

This starts a container from the jrwtango/expressrestaurantswagger image. The build configuration is used to build the image from the Dockerfile in the current directory. To specify environment variables, we use the environment configuration. The NODE_ENV variable is set to development to specify the environment for node. Finally ports is used to map the container's port 3000 to the host's port 3000. When running docker-compose up, the container will be started and the application will be available at http://localhost:3000.

References

Web Links

Note Links