Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use the docker container?

Shulou Source: shulou.com Published: 2022-06-01 03:21:41 09月26日 Update

Today, I will talk to you about how to use the docker container. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.

How to use the docker container? Docker container can solve a lot of problems, it is fast, lightweight, and the memory footprint is very small. As long as you allocate memory to the main process and add dozens of MB, starting a container is as fast as starting a single process. It doesn't take a few minutes, and you can start it in seconds. There are several principles we need to follow when creating a container that uses docker.

Do not create an oversized mirror

An oversized image will only be difficult to distribute. Make sure you only have the necessary files and libraries to run your application / process. Do not install unnecessary packages or run updates (yum updates) during creation.

Do not run more than one process in a single container

CCS can run a single process (http daemon, application server, database) perfectly, but if you have more than one process, you will have trouble managing, getting logs, and updating independently.

Do not store data in a container

Containers may be stopped, destroyed, or replaced. Version 1.0 of a program running in a container should be easily replaced by version 1.1 without affecting or losing data. For this reason, if you need to store data, store it in the volume, and note that it will crash if two containers write data on the same volume. Make sure your application is designed to write on a shared data store.

Run the process with a non-root user

"the docker container runs as root by default. As docker matures, more security default options become available. Nowadays, requesting root is dangerous for others and may not be available in all environments. Your image should use the USER directive to instruct a non-root user of the container to run."

Do not create a mirror for a running container

In other words, do not use the "docker commit" command to create a mirror. This method of creating a mirror is neither reproducible nor versioned and should be avoided completely. Always use Dockerfile or any other fully reproducible S2I (source-to-mirror) method

After reading the above, do you have any further understanding of how to use the docker container? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Container run process Mirror data content version Storage Application Update memory instruction method more user Service dangerous Security mature two Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn NVidia Redmi macOS Shulou Technology