docker-compose
The command is too long and tired.
We can use make
to help us save lives. After all, four letters are easier to remember than a bunch of letters.
The four most commonly used functions are encapsulated with make
:
-
build
build image -
up
(background) running service -
down
stop and delete the container (why use stop instead of down? stop just stops the container, down has a function to delete the container after stopping) -
logs
View incremental log
Makefile
file can be written like this:
NAME = ponponon/ideaboom
VERSION = 1.0.1
.PHONY: build up down logs
build: docker-build
up: docker-compose-up
down: docker-compose-down
logs: docker-compose-logs
docker-build:
docker build -t "${NAME}" .
docker-compose-up:
docker-compose up -d
docker-compose-down:
docker-compose down
docker-compose-logs:
docker-compose logs --tail=100 -f
-
NAME
= ponponon/ideaboom is the name of the image you want to package. You can use/
, it is legal -
VERSION
whatever, no point -
.PHONY
Reference: makefile .PHONY usage -
build
is used to build the image, you can directly make build after git pull, without the need fordocker build -t ponponon/ideaboom
such a long series of commands. -
up
is to restart the containers. -
logs
The most important thing, you can view the standard output, just use it to view the log.--tail=100 -f
means, first look at the100
line at the end, and then continue to output. Equivalent to the combination oftail
command-n
and-f
. If you don't want to read it, justctrl+c
exit
make
anddocker
have nothing to do with each other, hereMakefile
is just used to simplify the command
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。