Home Docker compose file
Post
Cancel

Docker compose file

At the root of the project create a file: docker-compose.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
version: '3'
services:
  api:
    image: conference/api
    container_name: conference_api
    build:
      context: .
    ports:
      - 5000:80
    environment:
      ASPNETCORE_ENVIRONMENT: Production
    depends_on:
      - postgres
  postgres:
    image: postgres:9.6.3
    container_name: conference_db
    environment:
      POSTGRES_DB: conference
      POSTGRES_USER: conf_app
      POSTGRES_PASSWORD: docker
    ports:
      - 5432:5432
    volumes:
      - ./db:/docker-entrypoint-initdb.d

To run the docker compose file

1
docker-compose up

To push your container to docker hub

1
docker tag {imageId} {username name}/{container name}:{tag name}

To log into your docker account

1
docker login
1
docker push {username}/{container name}:{tag name}
This post is licensed under CC BY 4.0 by the author.