Table of contents
Docker enables you to separate your applications from your infrastructure, so you can deliver software quickly. The programmings’ language for Docker is GO.
Docker is available on different operations systems. Follow this guide to install Docker.
A Container is a process, that has been isolated from the processes on the host machine.
An image is a filesystem of a docker Container, that also has been isolated from the filesystem of the host machine. There are all dependencies, config files, scripts and binaries from the running Application saved.
- The file
package.jsonlists all dependencies that the running application needs
- The file
Dockerfileis the description for Docker how to build the Docker Container
docker build -t getting-started . is the command to build a Container from the current folder and name it “getting-started”. The argument
-t name gives the Container a name.
To build a Docker Container you need the command
docker run <name>. useful arguments:
-dthis starts the Container in the background (“detached” mode)
-p 3000:3000maps the port 3000 of the Container to the port 3000 of the host system, to make it available from outside the Container.
To start the created docker container you can use the command
docker start <container_name>.
To run a command on a docker container you can use the command
docker exec -it <container_name> <command>. You can for example start a shell with this command:
docker exec -it <container_name> sh.
docker ps lists all Containers with some information.
docker stop <the-container-id> stops a Container. You can get the ID of the Container with the command
docker rm <the-container-id> removes the Container with the given ID. You need to stop the Container first. To stop it automatically, add the argument