-
Notifications
You must be signed in to change notification settings - Fork 0
Docker cheat sheet
We recommend to consider taking the course DevOps with Docker.
Install Docker Engine and Docker Compose according to the instructions.
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.
Run the program: sudo docker-compose up
Run the program taking consern possible modifications. sudo docker-compose up --build Shut down the program: sudo docker-compose down Run the unit tests: sudo docker-compose run qleader-web py.test The code coverage can be generated by: sudo docker-compose run qleader-web coverage run -m pytest Saving the coverage results can be done like this: sudo docker-compose run qleader-web coverage (e.g. "xml" / "json" / "html" ... more options with "--help")
Shutting down with:
docker-compose downAfter this check the ID of the docker container('s) that holds your database:
docker container ls -aAnd remove the container with the rm command (in this example the ID is 40d93a37 -- usually giving a few first characters is enough):
docker container rm 40dAfter this you can start your project again with the command
docker-compose up --buildIf there is changes that require more than Watchtower's restarting actions, do the following in the given order:
- Stopping the project (in the project folder with the docker-compose.yml -file):
docker-compose down- Listing running containers (perhaps want to see what's the names of the containers):
docker container lsTo see all the containers, even the stopped ones, add the flag -a.
- 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.
- Building project (in the beginning or if there are some bigger changes, for example, changes in the database)
docker-compose up --build -d- Restarting (might be needed if some changes has been made)
docker-compose restart- Note that restarting is useful in the project folder /qleader and in the /nginx