May 22, 2021 Docker From entry to practice
Most commands can run on one or more services. Without special instructions, this command can be applied to all services.
Perform
fig [COMMAND] --help
all the instructions for use.
--verbose
Show more information.
--version
Print the version and exit.
-f, --file FILE
With a specific Fig file, fig.yml is used by default.
-p, --project-name NAME
Use a specific project name, and the folder name is used by default.
build
Build or rebuild services.
Once a service is built, it will be marked as project_service, such figtest_db.
If you modify the
Dockerfile
service or build directory information, you can
fig build
to rebuild it.
help
Get help with a command.
kill
Force the service container to stop.
logs
View the output of the service.
port
The public port to which the print port is bound.
ps
All containers are listed.
pull
Pull the service image.
rm
Delete the stopped service container.
run
Execute a command on a service.
For example:
$ fig run web python manage.py shell
By default, linked services start unless they are already running.
The one-time command starts running in a new container with the same configuration as the normal container for the service, and then volumes, links, and so on are created as expected. The only difference with normal containers is that this command overrides the original command and is not created if there is a port conflict.
Links can also be created between one-time commands and other containers for that service, and then you can do something like this:
$ fig run db psql -h db -U docker
If you don't want to start a linked container when you execute a one-time command, you can specify the --no-deps option:
$ fig run --no-deps web python manage.py shell
scale
Set the number of containers that a service needs to run.
The quantity is set by the parameters of the service-num. For example:
$ fig scale web=2 worker=3
start
Start a container that the service already exists in.
stop
Stop a container that is already running, but do not delete it.
These
fig start
again with fig start.
up
Build, (re)create, start, link a container for a service.
Linked services will start unless they are already running.
By default,
fig up
the output of each container, and if the container already exists, all containers will stop.
If you run
fig up -d
containers will be up and running in the background.
By default, if the container for this service already exists,
fig up
will stop and re-create them (keep the volume mounted with volumes-from) to ensure that the changes to
fig.yml
take effect. I
f you don't want the container to be stopped and
fig up --no-recreate
If necessary, this will start the container that has stopped.
Environment variables can be used to configure fig behavior.
Variables DOCKER_, as are used to configure Docker's command-line clients.
If you're using
$(boot2docker shellinit)
set them to the correct values.
FIG_PROJECT_NAME
Set the name of the item added before each container launched through Fig. The default is the name of the current working directory.
FIG_FILE
Set the path
fig.yml
want to use.
The default path is the current working directory.
DOCKER_HOST
Set the URL of the docker process.
The default docker client
unix:///var/run/docker.sock
DOCKER_TLS_VERIFY
If you set characters that are not empty, TLS communication with the process is allowed.
DOCKER_CERT_PATH
Configure
ca.pem
cert.pem
key.pem
files for TLS validation.
The default path
~/.docker