migrate
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
---
|
||||
tags:
|
||||
- Documentation
|
||||
- Bookstack
|
||||
- Notes
|
||||
---
|
||||
# Docker
|
||||
|
||||
# Cheet Sheet Commands
|
||||
|
||||
## Running Containers
|
||||
|
||||
<table id="bkmrk-command-description-"><thead><tr><th>COMMAND</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td>`docker run <image>`</td><td>Start a new container from an image</td></tr><tr><td>`docker run -it <image>`</td><td>Start a new container in interactive mode</td></tr><tr><td>`docker run --rm <image>`</td><td>Start a new container and remove it when it exits</td></tr><tr><td>`docker create <image>`</td><td>Create a new container</td></tr><tr><td>`docker start <container>`</td><td>Start a container</td></tr><tr><td>`docker stop <container>`</td><td>Graceful stop a container</td></tr><tr><td>`docker kill <container>`</td><td>Kill (SIGKILL) a container</td></tr><tr><td>`docker restart <container>`</td><td>Graceful stop and restart a container</td></tr><tr><td>`docker pause <container>`</td><td>Suspend a container</td></tr><tr><td>`docker unpause <container>`</td><td>Resume a container</td></tr><tr><td>`docker rm <container>`</td><td>Destroy a container</td></tr></tbody></table>
|
||||
|
||||
## Container Bulk Management
|
||||
|
||||
<table id="bkmrk-command-description--1"><thead><tr><th>COMMAND</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td>`docker stop $(docker ps -q)`</td><td>To stop all the running containers</td></tr><tr><td>`docker stop $(docker ps -a -q)`</td><td>To stop all the stopped and running containers</td></tr><tr><td>`docker kill $(docker ps -q)`</td><td>To kill all the running containers</td></tr><tr><td>`docker kill $(docker ps -a -q)`</td><td>To kill all the stopped and running containers</td></tr><tr><td>`docker restart $(docker ps -q)`</td><td>To restart all running containers</td></tr><tr><td>`docker restart $(docker ps -a -q)`</td><td>To restart all the stopped and running containers</td></tr><tr><td>`docker rm $(docker ps -q)`</td><td>To destroy all running containers</td></tr><tr><td>`docker rm $(docker ps -a -q)`</td><td>To destroy all the stopped and running containers</td></tr><tr><td>`docker pause $(docker ps -q)`</td><td>To pause all running containers</td></tr><tr><td>`docker pause $(docker ps -a -q)`</td><td>To pause all the stopped and running containers</td></tr><tr><td>`docker start $(docker ps -q)`</td><td>To start all running containers</td></tr><tr><td>`docker start $(docker ps -a -q)`</td><td>To start all the stopped and running containers</td></tr><tr><td>`docker rm -vf $(docker ps -a -q)`</td><td>To delete all containers including its volumes use</td></tr><tr><td>`docker rmi -f $(docker images -a -q)`</td><td>To delete all the images</td></tr><tr><td>`docker system prune`</td><td>To delete all dangling and unused images, containers, cache and volumes</td></tr><tr><td>`docker system prune -a`</td><td>To delete all used and unused images</td></tr><tr><td>`docker system prune --volumes`</td><td>To delete all docker volumes</td></tr></tbody></table>
|
||||
|
||||
## Inspect Containers
|
||||
|
||||
<table id="bkmrk-command-description--2"><thead><tr><th>COMMAND</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td>`docker ps`</td><td>List running containers</td></tr><tr><td>`docker ps --all`</td><td>List all containers, including stopped</td></tr><tr><td>`docker logs <container>`</td><td>Show a container output</td></tr><tr><td>`docker logs -f <container>`</td><td>Follow a container output</td></tr><tr><td>`docker top <container>`</td><td>List the processes running in a container</td></tr><tr><td>`docker diff`</td><td>Show the differences with the image (modified files)</td></tr><tr><td>`docker inspect`</td><td>Show information of a container (json formatted)</td></tr></tbody></table>
|
||||
|
||||
## Executing Commands
|
||||
|
||||
<table id="bkmrk-command-description--3"><thead><tr><th>COMMAND</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td>`docker attach <container>`</td><td>Attach to a container</td></tr><tr><td>`docker cp <container>:<container-path> <host-path>`</td><td>Copy files from the container</td></tr><tr><td>`docker cp <host-path> <container>:<container-path>`</td><td>Copy files into the container</td></tr><tr><td>`docker export <container>`</td><td>Export the content of the container (tar archive)</td></tr><tr><td>`docker exec <container>`</td><td>Run a command inside a container</td></tr><tr><td>`docker exec -it <container> /bin/bash`</td><td>Open an interactive shell inside a container (there is no bash in some images, use /bin/sh)</td></tr><tr><td>`docker wait <container>`</td><td>Wait until the container terminates and return the exit code</td></tr></tbody></table>
|
||||
|
||||
## Images
|
||||
|
||||
<table id="bkmrk-command-description--4"><thead><tr><th>COMMAND</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td>`docker image ls`</td><td>List all local images</td></tr><tr><td>`docker history <image>`</td><td>Show the image history</td></tr><tr><td>`docker inspect <image>`</td><td>Show information (json formatted)</td></tr><tr><td>`docker tag <image> <tag>`</td><td>Tag an image</td></tr><tr><td>`docker commit <container> <image>`</td><td>Create an image (from a container)</td></tr><tr><td>`docker import <url>`</td><td>Create an image (from a tarball)</td></tr><tr><td>`docker rmi <image>`</td><td>Delete images</td></tr><tr><td>`docker pull <user>/<repository>:<tag>`</td><td>Pull an image from a registry</td></tr><tr><td>`docker push <user>/<repository>:<tag>`</td><td>Push and image to a registry</td></tr><tr><td>`docker search <test>`</td><td>Search an image on the official registry</td></tr><tr><td>`docker login`</td><td>Login to a registry</td></tr><tr><td>`docker logout`</td><td>Logout from a registry</td></tr><tr><td>`docker save <user>/<repository>:<tag>`</td><td>Export an image/repo as a tarball</td></tr><tr><td>`docker load`</td><td>Load images from a tarball</td></tr></tbody></table>
|
||||
|
||||
## Volumes
|
||||
|
||||
<table id="bkmrk-command-description--5"><thead><tr><th>COMMAND</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td>`docker volume ls`</td><td>List all vol1umes</td></tr><tr><td>`docker volume create <volume>`</td><td>Create a volume</td></tr><tr><td>`docker volume inspect <volume>`</td><td>Show information (json formatted)</td></tr><tr><td>`docker volume rm <volume>`</td><td>Destroy a volume</td></tr><tr><td>`docker volume ls --filter="dangling=true"`</td><td>List all dangling volumes (not referenced by any container)</td></tr><tr><td>`docker volume prune`</td><td>Delete all volumes (not referenced by any container)</td></tr><tr><td>`docker run --rm --volumes-from <container> -v $(pwd):/backup busybox tar cvfz /backup/backup.tar.gz <container-path>`</td><td>Backup a container</td></tr><tr><td>`docker run --rm --volumes-from <container> -v $(pwd):/backup busybox sh -c "cd <container-path> && tar xvfz /backup/backup.tar.gz --strip 1"`</td><td>Restore a container from backup</td></tr></tbody></table>
|
||||
|
||||
# Docker Install Script
|
||||
|
||||
This script is intended as a convenient way to configure docker's package # repositories and to install Docker Engine, This script is not recommended # for production environments. Before running this script, make yourself familiar # with potential risks and limitations, and refer to the installation manual # at [https://docs.docker.com/engine/install/](https://docs.docker.com/engine/install/) for alternative installation methods.
|
||||
|
||||
\# # The script:
|
||||
|
||||
\- Requires `root` or `sudo` privileges to run.
|
||||
|
||||
\- Attempts to detect your Linux distribution and version and configure your package management system for you.
|
||||
|
||||
\- Doesn't allow you to customize most installation parameters.
|
||||
|
||||
\- Installs dependencies and recommendations without asking for confirmation.
|
||||
|
||||
\- Installs the latest stable release (by default) of Docker CLI, Docker Engine, Docker Buildx, Docker Compose, containerd, and runc. When using this script to provision a machine, this may result in unexpected major version upgrades of these packages. Always test upgrades in a test environment before # deploying to your production systems.
|
||||
|
||||
\- Isn't designed to upgrade an existing Docker installation. When using the script to update an existing installation, dependencies may not be updated to the expected version, resulting in outdated versions.
|
||||
|
||||
\# # Source code is available at [https://github.com/docker/docker-install/](https://github.com/docker/docker-install/)
|
||||
|
||||
\# # Usage # ============================================================================== # #
|
||||
|
||||
To install the latest stable versions of Docker CLI, Docker Engine, and their # dependencies:
|
||||
|
||||
1\. download the script # # $ curl -fsSL [https://get.docker.com](https://get.docker.com) -o install-docker.sh
|
||||
|
||||
2\. verify the script's content $ cat install-docker.sh
|
||||
|
||||
3\. run the script with --dry-run to verify the steps it executes $ sh install-docker.sh --dry-run
|
||||
|
||||
4\. run the script either as root, or using sudo to perform the installation. $ sudo sh install-docker.sh
|
||||
Reference in New Issue
Block a user