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

How to use compose to define container name in docker

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article is about how to use compose to define container names in docker. Xiaobian thinks it is quite practical, so share it with everyone to learn. I hope you can gain something after reading this article. Let's not say much. Let's take a look at it together with Xiaobian.

docker compose defines the container name? Docker Compose describes the entire application in a declarative configuration file, enabling deployment with a single command. Docker Compose uses the directory name (counter-app) as the project name, Docker Compose adds the prefix counter-app_to all resource names.

A common way to launch a Compose app (multi-container apps defined by a Compose file are called "Compose apps") is with the docker-compose up command. It builds the required images, creates networks and volumes, and starts containers.

By default, docker-compose up looks for a Compose file named docker-compose.yml or docker-compose.yaml.

If the Compose file is another file name, it needs to be specified with the-f parameter.

The following command deploys the app based on a Compose file named prod-equus-bass.yml.

$ docker-compose -f prod-equus-bass.yml up

Docker Compose concatenates the project name (counter-app) with the resource name defined in the Compose file (web-fe) as the name of the newly built image. The names of all resources deployed by Docker Compose follow this specification.

The following command lists two containers. The name of each container is prefixed with the project name (the name of the directory in which it resides). In addition, they are all suffixed with a number to identify the container instance number, because Docker Compose allows for expansion and contraction.

$ docker container lsID COMMAND STATUS PORTS NAMES12.. "python app.py" Up 2 min 0.0.0.0:5000->5000/tcp counterapp_web-fe_157.. "docker-entry.. " Up 2 min 6379/tcp counterapp_redis_1

Running in the counterapp_web-fe container is the Web front end of the app. App.py is executed and mapped to Docker host port 5000.

The above is how to use compose to define container names in docker. Xiaobian believes that some knowledge points may be what we see or use in our daily work. I hope you can learn more from this article. For more details, please 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

Servers

Wechat

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

12
Report