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”.
2 Likes
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
1 Like