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 :
-
buildbuild image -
up(background) running service -
downstop 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) -
logsView 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 -
VERSIONwhatever, no point -
.PHONYReference: makefile .PHONY usage -
buildis used to build the image, you can directly make build after git pull, without the need fordocker build -t ponponon/ideaboomsuch a long series of commands. -
upis to restart the containers. -
logsThe most important thing, you can view the standard output, just use it to view the log.--tail=100 -fmeans, first look at the100line at the end, and then continue to output. Equivalent to the combination oftailcommand-nand-f. If you don't want to read it, justctrl+cexit
makeanddockerhave nothing to do with each other, hereMakefileis just used to simplify the command
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用。你还可以使用@来通知其他用户。