esolve
(Esolve)
March 10, 2020, 5:44pm
1
I use the following docker-compose.yml to start a container,
version: "2"
services:
nacos1:
image: nacos:latest
networks:
nacos_net:
ipv4_address: 10.0.2.10
ports:
- 8848:8848
volumes:
- /root/nacos/application.properties:/app/conf/application.properties
networks:
nacos_net:
ipam:
driver: default
config:
- subnet: "10.0.2.0/24"
I think the network name should be ânacos_netâ, but it is temp_nacos_net, what is wrong and how to fix this?
# docker network ls
NETWORK ID NAME DRIVER SCOPE
4e2323469ed0 temp_nacos_net bridge local
meyay
(Metin Y.)
March 10, 2020, 10:14pm
2
May I suggest to spend some time with online trainings to build up a basic understanding on Docker and Swarm?
â docker self paced training
â swarm self paced training
mgvazquez
(Manuel Andres Garcia Vazquez)
March 13, 2020, 5:48pm
3
Is there any chance that âtempâ is the name of the folder that contains the âdocker-compose.ymlâ?
esolve
(Esolve)
March 13, 2020, 10:25pm
5
yes, you are right, it is, how to remove it?
mgvazquez
(Manuel Andres Garcia Vazquez)
March 13, 2020, 10:26pm
6
As far as I know these is the common behavior of docker-compose; It use the parent folder name as âcontext/prefixâ for all the resources itâs controls.
Iâm sure that if you run âdocker ps -aâ, the ânacos1â container is named âtemp_nacos1â.
In the case of the network, if you really need use another name, You can create it with âdocker network createâ; and then reference it in the âdocker-composeâ as âexternalâ.
cjsethu1991
(Sethupandian Chandran)
May 26, 2023, 1:06pm
7
if you donât want your network name not to prefix with parent folder. as @mgvazquez suggests
create network:
docker network create nacos_net --subnet=10.0.2.0/24
and your docker-compose.yml should be like this
version: "2"
services:
nacos1:
image: nacos:latest
networks:
nacos_net:
ports:
- 8848:8848
volumes:
- /root/nacos/application.properties:/app/conf/application.properties
networks:
nacos_net:
external: true
name: nacos_net