Dev UtilitiesLesson 145Free preview
Docker Run to Compose
This lesson is part of Web Developer Tools · All levels
Summary
The tool translates the docker run command into an equivalent docker-compose.yml file, so that containers that were previously manually run can be managed declaratively. Compose writes images, ports, volumes, environments, and dependencies into one file that is easily shared. Once the file is created, the service can be run with a docker compose up.
Key points
- Docker run is imperative, Compose keeps the configuration in YAML
- Flag -p maps the host port to the container port
- Flag-v mounted volume or bind mount
- Flag -e sets the environment variable
- Docker compose up -d running the service in the background
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.