docker usage tips

Docker is really a smart way to hold projects with different environment settings. Below are some basic but must know cmds when using docker:

docker-compose is the name of the .yml file that used as the setting file for an app implemented in docker:

1. Start an app:
sudo docker-compose up
Notice when using like this, there is only one app info in the docker-compose file.  And then you will have the log console window keep running, means get the real time log info.
sudo docker-compose up -d
Notice -d option will run the docker container as a background app, and will not have server log info be displayed.

2. Stop an app:
sudo docker-compose stop
If any modification of the code, then need to "stop" and "up" the app. 

3. Show the running containers:
sudo docker ps
Can get "CONTAINER ID", "IMAGE NAMES" and other basic info for all the running containers.

4. Show the server log file:
sudo docker logs CONTAINER_ID
Or use the docker-compose:
sudo docker-compose logs
An example:
sudo docker logs e23b61a280e2
Show the real time log file:
sudo docker logs e23b61a280e2 -f
Stop the real time log by Ctrl+C, will not stop the app.
Check detail https://docs.docker.com/engine/reference/commandline/logs/

5. Get in the docker container:
sudo docker exec -it app bash
A simplify/shorter cmd :
docker-compose exec app bash

Comments

Popular posts from this blog

install ipython in Cloudera VM using pip

install postgreSQL in ubuntu 16.04

Install MYSQL 5.6 in ubuntu 12.04/14.04 and set password and remote access