Docker Essentials
Docker Essentials
Basic terms
Text document that contains all the commands a user could call on the command
line to assemble an image.
Dockerfile Put simply, Dockerfile is configuration file that “tell” Docker images what to install,
update, etc. Basically the Docker file says what to build that will be the Docker
image.
File contains read-only set of processes outlined in the Docker file. It is helpful to
think of these as templates created by the Docker files.
Docker image A Docker image is roughly equivalent to a "snapshot" in other virtual machine
environments.
Docker container is a standard unit of software that stores up code and all its
dependencies, so the application runs fast and reliably from one computing
Docker container environment to different ones. A Docker container image is a lightweight,
standalone, executable package of software that has everything you need to run an
application – code, runtime, system tools, system libraries, and settings.
Container workflow: create Dockerfile
touch Dockerfile
run container as daemon keep container alive image to use for the container
Launch specific command inside container if we want to build something using dedicated environment
command inside the container will use this directory as current inside the container execute bash with an args
mount current host directory inside the container image to use for the container
Containers: shared resources
All data generated in container are stays in container. If you recreate the container
Volumes you loose all your data. Volumes are the preferred mechanism for persisting data
generated by and used by Docker containers.
By default, when you create a container, it does not publish any of its ports to the
Ports outside world. To make a port available to services outside of Docker, or to Docker
containers which are not connected to the container’s network, use the --publish
or -p flag.
Docker created it`s own network for the containers. The container interface can
Networks be attached to the host by the several ways. Please read the official
documentation to use the best way, or simply use default settings.
Containers: interaction
Shows list of active containers
docker ps
Launch shell inside the container Shows stdout for the container
specifies user container name command follow the output container name
run command inside terminal in interactive mode shows only last 5 min of an output
Grouping containers version: "3.5"
services:
nms:
container_name: "nms-${BEAM_ID}"
image: registry.spacebridge.com/nms5:5.0.0.4.dev16.mr185.Sergey_Kolotsey.b5
Compose is a tool for defining and running restart: always
multi-container Docker applications. With privileged: true
Compose, you use a YAML file to configure ports:
- ${MY_IP}:20:20/tcp
your application’s services. - ${MY_IP}:21:21/tcp
## several lines ckipped
docker-compose.yml is a simple way to keep - ${MY_IP}:22:22
all startup parameters in one place. - ${MY_IP}:32769:32769/udp
volumes:
- /srv/docker/nms/log:/var/log
- pgdata:/var/lib/pgsql
You also can use environment variables to - C:/C
simplify setup networks:
net:
environment:
- PAIR_IP
- BEAM_ID
- VRRP_IP
- CENTRAL_NMS_IP
volumes:
C:
pgdata:
networks:
net:
Docker compose overview ipam:
config:
- subnet: 172.20.${BEAM_ID}.0/24
Questions?
[email protected]
Skype: arbuzovsergey