No edit summary
No edit summary
Line 14: Line 14:
The [https://docs.docker.com/engine/reference/builder/ Dockerfile Reference] describes the commands that can be issued in a Dockerfile  
The [https://docs.docker.com/engine/reference/builder/ Dockerfile Reference] describes the commands that can be issued in a Dockerfile  
<br />
<br />
== Docker Compose ==
Docker Compose takes the role of the Docker command line interface and lets you send commands to the Docker engine by elegantly specifying a build/run configuration in a YAML file instead of, e.g., creating a shell script with Docker CLI commands. For example, the following Docker commands for building an image and instantiating a container
<pre class="terminal">
docker build -t my-app .
docker run --rm -tip 3000:3000 -n my-app my-app
</pre>
can be be expressed by this '''docker-compose.yml''' file:
<pre class="code">
version: "3.8"
services:
  app:
    build: ./
    ports:
      - 3000:3000
</pre>
<br/>
The configuration defined in the YAML file is then realized with the command
<pre class="terminal">
docker-compose up --build
</pre>
where the ''--build'' option triggers a rebuild of the image. Note also that ''docker-compose'' automatically removes containers that have exited.
<br/>

Revision as of 2021-05-29T13:26:03

Installing

Visit Docker's documentation installing Docker engine on Ubuntu for instructions on how to install the very latest version, including the Docker GPG keys. You can also install Docker from Ubuntu's own package repositories via

sudo apt install docker.io

Dockerfile

The environment inside of a Docker image is defined by the instructions that the Docker image builder picks up from a file. The default expected name for this file is Dockerfile. If your Dockerfile has a different name, you need to provide that file name to the build command:

docker build -t MyImage -f /path/to/MyDockerFileName


The Dockerfile Reference describes the commands that can be issued in a Dockerfile

Docker Compose

Docker Compose takes the role of the Docker command line interface and lets you send commands to the Docker engine by elegantly specifying a build/run configuration in a YAML file instead of, e.g., creating a shell script with Docker CLI commands. For example, the following Docker commands for building an image and instantiating a container

docker build -t my-app .
docker run --rm -tip 3000:3000 -n my-app my-app

can be be expressed by this docker-compose.yml file:

version: "3.8"
services:
  app:
    build: ./
    ports:
      - 3000:3000


The configuration defined in the YAML file is then realized with the command

docker-compose up --build

where the --build option triggers a rebuild of the image. Note also that docker-compose automatically removes containers that have exited.


Debug data: