(1) Create a directory for the persistent database
I've chosen to store the data within /data
sudo mkdir -p /data/_customer_name_/
(2) Create a directory for the application data
I've chosen to store the app under /app
cd /app mkdir _customer_name_ cd _customer_name_/
(3) Pull in the container bootstrap code
This will copy in the necessary files to create a Docker image
git clone https://github.com/markciecior/container_bootstrap.git .
(4) Pull in the application code
This will copy in the Python code used to run the website
git clone 'REPO_NAME' code/_APPNAME_
(5) Create the Docker images
The application code will live in one container, the database in another. We can pull a generic postgres database container from Docker Hub, but we'll build the application image ourselves.
docker build -t cait/_customer_name_django .
(6) Set the host as a Swarm manager
This is only done once per host, and has likely been done already
docker swarm init
(7) Create a stack of services using the docker-compose YAML file
This YAML file defines what services constitute our application stack. We're using one DB server and one web/app server.
stack deploy -c docker-compose.yml _customer_name
To see the stacks deployed on this host:
docker stack ls
To see the services (tasks) running for a particular stack:
docker stack services 'STACK_NAME'
To see the currently running containers (and their IDs):
docker container ls
To see the console output from a running container, using the container ID from the previous command:
docker logs 2184e2bd9dce #<-- use the container ID here