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:
2. Stop an app:
3. Show the running containers:
4. Show the server log file:
Show the real time log file:
5. Get in the docker container:
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 upNotice 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 -dNotice -d option will run the docker container as a background app, and will not have server log info be displayed.
sudo docker-compose stopIf any modification of the code, then need to "stop" and "up" the app.
3. Show the running containers:
sudo docker psCan get "CONTAINER ID", "IMAGE NAMES" and other basic info for all the running containers.
4. Show the server log file:
sudo docker logs CONTAINER_IDOr use the docker-compose:
sudo docker-compose logsAn example:
sudo docker logs e23b61a280e2
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/
Check detail https://docs.docker.com/engine/reference/commandline/logs/
sudo docker exec -it app bashA simplify/shorter cmd :
docker-compose exec app bash
Comments
Post a Comment