docker daemon
Enable buildkit
Add to /etc/docker/daemon.json
:
docker-compose
- LZone Cheats Sheets. Docker Compose Cheat Sheet Edit Cheat Sheet Setup Troubleshooting Couldn’t connect to Docker daemon at http+docker://localhost - is it running?
- Docker Compose Cheat Sheet by Gaurav Pandey (gauravpandey44) via cheatography.com/69622/cs/20583/ Basics Dock er- Com pose: is a tool for defining and running multi- con tainer Docker applic ations. With Compose, you use a YAML file to configure your applic.
Devices
Docker Cheat Sheet Build Build an image from the Dockerfile in the current directory and tag the image docker build -t myimage:1.0. List all images that are locally stored with the Docker Engine docker image ls Delete an image from the local image store docker image rm alpine:3.4 Share Run Run a container from the Alpine version 3.9.
Labels
External Network
Dockerfile
Docker Stop Signal
imagemagick
vim
Docker Compose 3 Cheat Sheet
path update
download & extract tar.gz
gpg dirmgr explained
purge
list what exposed ports do
cassandra
gosu
Docker Compose Cheat Sheet
debian
copy with proper permissions
su-exec
setgid
npm
gosu
tini
node
redis
docker
google cloud sdk
kubectl
pip
locale
tomcat
https://github.com/Unidata/tomcat-docker/blob/master/Dockerfile
gosu tomcat
Secure repository setup
create application folder structure
Download and clean up in one layer
Package Manager tricks
Metadata
Make sure to add ARG
statements as late as possible to not invalidate the layer cache needlessly.Each ARG
will be prepended to all subsequent RUN
statements, i.e. building an image with the following Dockerfile docker --pull --tag foo:latest --build-arg GIT_COMMIT=46e24af6 --build-arg USERNAME=flask .
Effectively results in the following calls:
Since the git commit hash will typically change with each build the build will not make good use of Docker’s layer cache
Python
Golang
An overview of the most important commands for managing Sitecore with Docker.
The official Docker documentation is very good, but it can be difficult to navigate. This topic lists some of the most useful commands for managing Sitecore with Docker in local development environments.
The examples assume that you use PowerShell as your command shell.
These commands show various information about Docker itself:
To list all available commands:
You can display detailed information for any specific command using
--help
:To display high-level information for your Docker environment (version, root directory, default isolation mode, and so on):
You use these commands to manage images:
To list images (use
-a
to include intermediate images):You can format the results with the
--format
option. See the Docker documentation for a list of valid placeholders.To remove images:
The
<image>
can be either the image ID or full name. The ID only requires the minimum number of characters to uniquely identify it. For example, given this image list:All 3 of these commands remove the nanoserver image:
To remove all images:
To be more selective, use image list formatting combined with
findstr
. For example, to remove all images with a specific name or tag:To inspect images:
This displays detailed information for an image, including:
ID: The full unique identifier of the image.
WorkingDir: The folder you are in when you run an interactive shell in the image. You use this when you extend an image with your own customizations.
Entrypoint: The default entrypoint when you run this image in a container. This is useful information when you use the image in Docker Compose, which allows overriding.
VirtualSize: The size of the image in bytes.
You can format the output.
You use these commands to manage containers:
To list containers (use
-a
to include stopped containers):You can filter the results using the
-f
(or--filter
) option. For example, to show just the running Sitecore CM images:You can format the results with the
--format
option. See the Docker documentation for a list of valid placeholders.To remove containers (use
-v
to remove volumes as well):Similar to images, the
<container>
can be either the container ID (full or partial) or full name.To remove all stopped containers:
(Add
--force
to remove running containers as well.)To inspect containers:
This displays detailed information for a container, including the following:
ID - the full unique identifier of the container.
Image - the image the container is running.
NetworkSettings - the network information including the Ports, IPAddress, and any Aliases.
LogPath - the file system path to the container's log file.
Volumes - displays any volume mappings between the host system and the container.
WorkingDir - this is where you are dropped when running an interactive shell in the container.
You can format the output.
To start and stop containers individually:
However, when you develop with Sitecore, you usually have multiple containers and use Docker Compose to start and stop containers.
To copy files between containers and the local file system:
For example, to copy a file to a container:
Or to copy a folder from a container:
Note
Your containers must be running with process isolation for this. File system operations with Hyper-V container are not supported.
To display logs:
You can stream the log output using
-f
(or--follow
):Type
Ctrl+C
to exit.Most containers generate a lot of entries, so you can use the
--tail
or--until
options to limit the amount. For example, to display only the last 20 log entries:
Many of the Docker commands provide the --format
or -f
option to format results, which allows you to format the output for display or even to pass to other scripts. The format string follows Go templating.
For inspect commands, the output data is already in JSON format, so the data structure is straightforward.
Some examples:
To get a container's image name:
To get a container's IP address:
The output from list commands is in a table format. The Docker documentation (see here for images, here for containers) has details about the available properties, or you can format the output as JSON as follows:
To show a custom image list:
To show a custom container list, using the
table
directive:
You can open an interactive shell prompt inside a Windows image. You can only use powershell
in images that support it. If omitted, the default cmd
shell is used:
Type exit
to return out of the container to your previous shell session.
This starts a new container (run
), goes into an interactive shell (-it
), and then destroys the container after you exit (--rm
).
This does not work for all images, depending on the default ENTRYPOINT
. If this is the case, run it in detached mode:
Then run an interactive shell in the running container.
You can open an interactive shell prompt inside a running Windows container using the following.You can only use powershell
in containers that support it:
Type exit
to return out of the container to your previous shell session.
Docker does not remove unused resources automatically. Unnecessary resources can therefore accumulate over time and use up disk space.
The most useful command to solve this issue is:
By default, you are prompted to continue. To bypass, use the -f
(or --force
) option.
This command removes:
All stopped containers.
All networks not used by at least one container.
All dangling images (not tagged and not referenced by any container).
All build caches.
This default is generally safe to use at any time. You can add the following options to be more aggressive about it:
--volumes
- Removes all volumes not used by at least one container-a
(or--all
) - Removes all images without at least one container associated with them
There are prune
commands for each individual Docker object (image, container, and so on), but those are used less often. See the Docker documentation for details.
Docker Cheat Sheet Pdf
You run these commands from the location of your Compose file. They assume that your Compose file is called docker-compose.yml
. They will also automatically load an additional docker-compose.override.yml
, if such a file is present.
If your Compose files are named something else, use the -f
flag to specify explicitly:
You can specify as many files as you need. Compose combines them into a single configuration based on the order, with subsequent files overriding/adding to their predecessors.
You can view the aggregated result using config
. For example:
This shows your resolved application configuration, including combined compose files, .env
, and so on. You can also add the name of one or more services. This allows you to target individual services or containers. For example, given the following Compose file:
Docker-compose Cheat Sheet
You can restart
just the id and cm containers:
Docker-compose Commands Cheat Sheet
To create and start containers:
This creates and run containers for all services that you have defined in your Compose configuration.
The
-d
(detached mode) starts the containers in the background and leaves them running. If you omit this, the container logs are streamed to the output, and you need to typeCtrl+C
to return to a prompt. This also stops and removes your containers.To stop containers:
This stops containers but does not remove the containers.
To start containers:
This starts existing containers that you have previously stopped.
To restart containers:
This restarts all stopped and running containers.
To stop and remove containers:
This stops all containers gracefully, and once all are stopped, it removes them. Any networks created by
up
are also removed. Use-v
to remove volumes.To list containers:
You can list the names of the services instead with the
--services
option. Use-a
to include stopped containers.To build images:
This builds and creates images for all services that define a
build
.You can use the
--build
option withup
. This rebuilds and runs containers with the latest code:To display logs:
This displays the logs from all containers. You can use the
--tail
option to limit the number of lines, and filter for specific containers. For example, to display only the last 20 log entries from yourcm
andxconnect
containers:You can also stream the log output with the
-f
(or--follow
) option:Type
Ctrl+C
to exit.