[Docker] Docker-compose auto-start after lauching AWS EC2 server

Posted by qwlake on December 13, 2020
  1. Enable docker daemon
    1
    
    sudo systemctl enable docker
    
  2. Add restart option to docker-compose.yml
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    web:
    restart: always
    build: .
    container_name: web01
    command: bash -c "
        python manage_dev.py collectstatic --no-input &&
        python manage_dev.py makemigrations && 
        python manage_dev.py migrate &&
        gunicorn knu_notice.dev.wsgi -b 0:8080 --reload"
    volumes:
        - ./knu_notice:/home/knu_notice
    links:
        - redis