0% found this document useful (0 votes)
113 views9 pages

Docker Essentials

Debian docker-compose commands

Uploaded by

helder.depena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views9 pages

Docker Essentials

Debian docker-compose commands

Uploaded by

helder.depena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

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

Comments starts from # #Dockerfile example


FROM centos:6.10
Basic image. Created and maintained by
the OS developers community
RUN yum install -y java-1.8.0-openjdk-devel openssh-server sudo

ADD ./iso /media/iso


Execute additional commands
VOLUME "/var/lib/pgsql/data“
Include external files
CMD ["/run.sh"]
Declare directory as volume to store data
outside the container

Define startup command


Dockerfile reference
Container workflow: get an image
At the directory contains Dockerfile execute

docker build . -t my_new_image

This command creates an image locally and name it


Public docker storage
Local SpaceBridge storage
You can use pre-build images from external storage
docker pull shared_image

This command will try to download image from shared resource


Container workflow: launch container
Launch container as daemon useful if we want to start our application as service

define container name map container port to the host port

docker run -d --name nms01 --restart=unless-stopped -p 443:443 registry.spacebridge.com/nms5:5.0.0.4.dev17.b133

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

docker run -v ${PWD}:/tmp/corenms -w /tmp/corenms/nms_server_update_tools corenms-build:latest /bin/bash -c "./mknmsupdateiso 5.x.x"

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

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES


e44eedd42047 elk_logstash "/usr/local/bin/dock…“ 4 days ago Up 2 hours 5044/tcp, 9600/tcp logstash
b89d8b3ec2b3 elk_kibana "/usr/local/bin/dumb…“ 4 days ago Up 2 hours 0.0.0.0:5601->5601/tcp kibana
165e189b36bb elk_elasticsearch "/usr/local/bin/dock…“ 4 days ago Up 2 hours 0.0.0.0:9200->9200/tcp elasticsearch

Launch shell inside the container Shows stdout for the container

specifies user container name command follow the output container name

docker exec -ti -u root my_container /bin/bash


docker logs --follow --since 5m my_container

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

You might also like