0

Depending on the host where I'm running Docker-compose, I get different network naming. For instance:

This is my docker-compose file:

./my-project-folder/docker-compose.yml

version: '3'

services:

  search:
    build: docker/server
    container_name: server
    ports:
      - 9200:9200

I have a project called my-project-folder and the network is called:

my-project-folder_default

But sometimes I get this network name:

myprojectfolder_default

Is there a way to have consistent network names?

2
  • 1
    Can you share your docker compose? Commented Jul 17, 2018 at 14:23
  • Added docker compose file @juanlumn Commented Jul 18, 2018 at 8:50

2 Answers 2

1

docker-compose -p or the COMPOSE_PROJECT_NAME environment variable will manually set that prefix, rather than letting Compose decide for itself based on the directory name. This would still let you have multiple copies of the stack running on the same system if you needed to (forcing container_name and the network name would cause multiple deployments to conflict).

Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried defining an entry under networks?

version: '3'

services:

  search:
    build: docker/server
    container_name: server
    ports:
      - 9200:9200
    networks:
      - your-network-name

networks:
  your-network-name: ...

There is some interesting information in the Compose File Reference V3 Documentation

According to the previous doc:

version: '3.5'

services:
  search:
    build: docker/server
    container_name: server
    ports:
      - 9200:9200
    networks:
      - your-network-name

networks:
  your-network-name:
   name: your-global-net

Please note that you will need at least Docker Engine 17.06.0 for this to work and you need to use the latest version of docker-compose yml.

To check that you can simply type:

docker version

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.