Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Comparative Analysis of commands in docker and compose

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the comparative analysis of commands in docker and compose, which is very detailed and has a certain reference value. Friends who are interested must finish it!

Contrast

Image vs build

Image: if the image does not exist locally, Compose will try to pull it out.

Build: specify the path to the folder where Dockerfile is located. Compose will use it to automatically build the image and then use the image.

● links vs external_links

Links: links to containers in other services. Use either the service name (also as an alias) or the service name: service alias (SERVICE:ALIAS) format. The alias used will be automatically created in / etc/hosts in the service container.

External_links: links to containers outside of docker-compose.yml, not even Compose-managed containers.

Ports vs expose

● ports

Expose port information. Use: host: container (HOST:CONTAINER) format or just specify the port of the container (the host will randomly select the port).

When using HOST:CONTAINER format to map ports, if you use a container port less than 60, you may get an error result, because YAML will parse xx:yy as a number format of 60. Therefore, it is recommended to use the string format.

● expose

The port is exposed, but not mapped to the host, and is only accessed by the connected service.

Only internal ports can be specified as parameters

Volumes vs volumes_from

● volumes

Volume mount path settings. You can set the host path (HOST:CONTAINER) or add the access mode (HOST:CONTAINER:ro).

Ro means readonly, read-only mode.

● volumes_from

Mount all its volumes from another service or container.

Note:

The Compose environment variable indicates that the environment variable is no longer the recommended way to connect to the service; instead, you should use the link name (by default, the name of the linked service) as the host name, which can be seen in more detail of docker-compose.yml. Compose uses Docker links to expose the service's containers to others. Each linked container uses a set of environment variables, each of which begins with an uppercase letter of the container name. To view the environment variables available to the service, run docker-compose run SERVICE env

The above is all the contents of the article "Comparative Analysis of commands in docker and compose". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report