Skip to content

Docker cheat sheet

Matias Tamsi edited this page Aug 25, 2021 · 15 revisions

We recommend to consider taking the course DevOps with Docker.

Installation

Install Docker Engine and Docker Compose according to the instructions.

Working with

Here are useful commands gathered that are essential when working with the project.

See that docker and docker-compose might require sudo rights. Luckily this isn't the case in the ohtup-staging but propably on your own machine. One possible solution is in here.

Developing

Run the program:

docker-compose up

Run the program taking concern possible modifications.

docker-compose up --build

Shut down the program:

docker-compose down

Listing the containers ('a' indicates that show even stopped ones):

docker container ls -a

Testing

More about Testing.

Run the unit tests:

docker-compose run qleader-web py.test

The code coverage can be generated by:

docker-compose run qleader-web coverage run -m pytest

Saving the coverage results can be done like this:

docker-compose run qleader-web coverage <option> (e.g. "xml" / "json" / "html" ... more options with "--help")

Start with a clean sheet example

Here are the commands in the right order to be done in the staging, if there are changes that require more than Watchtower's restarting actions:

  1. Stopping the project (in the project folder with the docker-compose.yml -file):

     docker-compose down
    
  2. Listing running containers (perhaps want to see what's the names of the containers):

     docker container ls
    

    To see all the containers, even the stopped ones, add the flag -a.

  3. Removing container (removing your project's old containers might be needed when creating new ones):

     docker container rm qleader-db  # Here is an example so replace the container name "qleader-db" with correct one!
    
    • See that the container is stopped before trying to remove it. For this there are more options like stop and kill (or docker-compose down, if you are in the project folder) depending on the situation.
  4. Building project (in the beginning or if there are some bigger changes, for example, changes in the database)

     docker-compose up --build -d
    
  5. Restarting (in the folder /nginx):

     docker-compose restart
    

    Can also be done in the /qleader if needed.

Repositories

Clone this wiki locally