Using docker technology

In previous part we talk about how to install and prepare system for runing docker and now few command that we need to running docker container.

Before we can run docker conteiner we need build the docker image.
Docker image we build based on Dockerfile.

Building docker image

For build image we need to go into folder where is file with name “Dockerfile” use this command

docker build -t my_image 

Running the docker container

now we start docker cointaner, basicaly is the instance of image. We can start how many containers we want from one docker image.

docker run -itd -v $(pwd)/source:/target my_image

What this command does doing?
its starts cointainer in interactive mode that means
 it take you straight inside of the container (-it) and (-d) means that its running on baground. -V means connecting folder on Host OS with folder inside Docker container. Basically you cen get data from outside into docker container.

Cleaning

If we want do delete Docker Images and Docker containers, docker container does not have to running. So before we can delete all we have to stop all Docker containers.

docker container stop $(docker container ls -a -q)

This command can stop and delete everything in one step

docker container stop $(docker container ls -a -q) && docker system prune -a -f --volumes

Docker compose

Docker Compose is a tool for defining and running multi-container Docker applications. To define the configuraton you use
docker-compose.yml. Then, with a single command ,
docker-compose up -d you create and start all the services (docker containers) from your configuration file (
docker-compose.yml).

For the more information about keywords and format of
docker-compose.yml click on this link.

Leave a Reply

Close Menu