Reputation: 9469
I have following docker-compose.yml
:
version: '3.5'
services:
postgres:
container_name: my_container
image: postgres:9.6.16-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER:-xxxx}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-xxxx}
PGDATA: /data/postgres
volumes:
- postgres:/data/postgres
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
ports:
- "31338:5432"
networks:
- postgres
restart: unless-stopped
networks:
postgres:
driver: bridge
volumes:
postgres:
This is docker image with empty postgres database. It initializes and works fine, the only thing I don't like is how it looks like in Docker Dashboard:
There is db
parent folder which is the name of the folder the docker-compose.yml is located in. I would like to avoid this parent folder.
What should I change in my docker-compose.yml
to get rid of parent folder?
Upvotes: 4
Views: 1055
Reputation: 16997
You won't be able to avoid this project-name unless you modify UI of dashboard, however you can change project-name using -p
option.
By default project-name will use the name of the folder containing your docker-compose.yml
.
To override with someother name you can use -p
option like below
# docker-compose -p <project_name-goes-here> up -d
-p, --project-name NAME Specify an alternate project name
(default: directory name)
COMPOSE_PROJECT_NAME
Sets the project name. This value is prepended along with the service name to the container on start up. For example, if your project name is myapp and it includes two services db and web, then Compose starts containers named myapp_db_1 and myapp_web_1 respectively.Setting this is optional. If you do not set this, the
COMPOSE_PROJECT_NAME
defaults to the basename of the project directory. See also the -p command-line option.
Upvotes: 7