Some basic concepts and commands are commonly used in Docker

in Docker


Directives in Dockerfile such as RUN, FROM, CMD … to perform tasks that automatically generate Docker images. File docker-compose.yml to create services to run specific applications, for example create Apache, MySQL, PHP-FPM,…

 

docker-image-container

 

 

1. Dockerfile

Directives in Dockerfile such as RUN, FROM, CMD … to perform tasks that automatically generate Docker images.

Use the interactive Docker commands to get the image, create the container, run and install the components into the container … A lot of work in this process can be saved to a file called Dockerfile. Tell Docker to read the file and run each command according to the instructions in that file to get the desired image.

 

2. Docker compose

File docker-compose.yml to create services to run specific applications, for example create Apache, MySQL, PHP-FPM, Memcached services and install the application to run the project (Laravel, WordPress, …) .

The definition is quite similar to Dockerfile, docker-compose generates and manages services (containers), networks, drives … for a complete application.

When writing note spaces, tabs from the beginning of the line

 

3. Commands are commonly used in Docker

– Docker images and container

docker images: show all images
docker image rm id: remove image
docker image rm id -f (id1, id2, id3, ..): force removal multi images

docker ps: show all container running
docker ps -a: show all container
docker rm id: remove container

 

– Build and run container from docker-compose.yml (The first build takes a long time)

docker-compose build && docker-compose up -d (d: Detached mode)

– Build to create images, start containers from images

docker-compose down: Stop and remove containers, networks
docker-compose up -d: Run containers in the background

 

docker-chart-create-start-running-pause

Docker create – start – running – pause – deleted

Tags: , , ,

Your comment

Please rate

Your comment is approved before being displayed.
Your email address will not be published. Required fields are marked *


*
*
*