Docker
Overview:
Install:
Network (Docker for Windows):
<Container> ┌─────┐┌─────┐ │ eth0 ││ eth0 │ │ (veth*) ││ (veth*) │ └──┬──┘└──┬──┘ ┌──┴──┐┌──┴──┐ │ veth* ││ veth* │ 172.17.0.0/16 ┌───────────┐├─────┴┴─────┤ │ <DockerClient> ││ vBridge(docker0) │ <DockerHost> ┌───┴───────────┤├────────────┤ Host OS │ Windows10 ││ MobyLinux │ VM └┬─────┬─┬─────┬┘└──┬──────┬──┘ 192.168.1.0/24 │ vEth │ │ vEth │ │ eth0 │ 10.0.75.0/24 └──┬──┘ └──┬──┘ └───┬──┘ ┌──┴──┐ ┌──┴───────────┴───┐ Hyper-V │ vSwitch │ │ vSwitch(DockerNAT) │ └──┬──┘ └──────────────────┘ ┌──┴──┐ │ NIC │ └──┬──┘
:
$ docker images $ docker ps -a $ docker ps -aqf status=exited $ docker images -qf dangling=true $ docker system prune -a # all images $ docker rmi $(docker images -aqf dangling=true) # all of <none> $ docker rm $(docker ps -aq) tail -f /dev/null # tail がフォアグラウンドで起動し続けてくれる
:
image: - ID # 64Digits - Repository:Tag - Created time - Size container: - ID - Name - Image - Command - Port - Created time - Size - Status https://docs.docker.com/docker-cloud/builds/image-scan/
Docker:
comm: doker usag: $ docker [OP] <COMMAND> shel: $ docker ps shel: $ docker image ls opti: - --config <PATH> # Config file (default:USER\.docker") - -D, --debug # Debug mode - -H, --host <list> # Daemon socket(s) to connect to - -l, --log-level <LEVEL> # Set the logging level (default:info) # debug/info/warn/error/fatal - --tls # Use TLS - --tlscacert <string> # Trust certs signed only by this CA - --tlscert <string> # Path to TLS certificate - --tlskey <string> # Path to TLS key - --tlsverify # Use TLS and verify the remote - -v, --version # Show version
Commands:
Commands: attach # Attach local standard input/output/error to a running container build # Build an image from a Dockerfile commit # Create a new image from a container's changes cp # Copy files/folders between a container and the local create # Create a new container deploy # Deploy a new stack or update an existing stack diff # Inspect changes to files or directories on a container events # Get real time events from the server exec # Run a command in a running container export # Export a container's filesystem as a tar archive history # Show the history of an image images # List images import # Import the contents from a tarball to create a filesystem image info # Display system-wide information inspect # Return low-level information on Docker objects kill # Kill one or more running containers load # Load an image from a tar archive or STDIN login # Log in to a Docker registry logout # Log out from a Docker registry logs # Fetch the logs of a container pause # Pause all processes within one or more containers port # List port mappings or a specific mapping for the container ps # List containers pull # Pull an image or a repository from a registry push # Push an image or a repository to a registry rename # Rename a container restart # Restart one or more containers rm # Remove one or more containers rmi # Remove one or more images run # Run a command in a new container save # Save one or more images to a tar archive (default:STDOUT) search # Search the Docker Hub for images start # Start one or more stopped containers stats # Display a live stream of container(s) resource usage statistics stop # Stop one or more running containers tag # Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE top # Display the running processes of a container unpause # Unpause all processes within one or more containers update # Update configuration of one or more containers version # Show the Docker version information wait # Block until containers stop, then print their exit codes Management Commands: checkpoint: # --<< Checkpoints >>-- - create # Create a checkpoint from a running container - ls # List checkpoints for a container - rm # Remove a checkpoint config: # --<< Configs >>-- - create # Create a configuration file from a file or STDIN - inspect # Display detail configuration files - ls # List configs - rm # Remove one or more configuration files container: # --<< Containers >>-- - attach # Attach local standard input/output/error to a container - commit # Create a new image from a container's changes - cp # Copy files/folders between a container and the local - create # Create a new container - diff # Inspect changes to files/directories on a container - exec # Run a command in a running container - export # Export a container's filesystem as a tar archive - inspect # Display detailed information on one or more containers - kill # Kill one or more running containers - logs # Fetch the logs of a container - ls # List containers - pause # Pause all processes within one or more containers - port # List port mappings or a specific mapping for the container - prune # Remove all stopped containers - rename # Rename a container - restart # Restart one or more containers - rm # Remove one or more containers - run # Run a command in a new container - start # Start one or more stopped containers - stats # Show a live stream of containers resource usage statistics - stop # Stop one or more running containers - top # Display the running processes of a container - unpause # Unpause all processes within one or more containers - update # Update configuration of one or more containers - wait # Block until containers stop, then print their exit codes image: # --<< Images >>-- - build # Build an image from a Dockerfile - history # Show the history - import # Import contents from a tarball to create a filesystem image - inspect # Display detail - load # Load an image from a tar archive or STDIN - ls # List images - prune # Remove unused images - pull # Pull an image or a repository from a registry - push # Push an image or a repository to a registry - rm # Remove images - save # Save images to a tar archive (default:STDOUT) - tag # Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE network: # --<< Networks >>-- - connect # Connect a container to a network - create # Create a network - disconnect # Disconnect a container from a network - inspect # Display detailed information on one or more networks - ls # List networks - prune # Remove all unused networks - rm # Remove one or more networks node: # --<< Swarm nodes >>-- - demote # Demote one or more nodes from manager in the swarm - inspect # Display detailed information on one or more nodes - ls # List nodes in the swarm - promote # Promote one or more nodes to manager in the swarm - ps # List tasks running on one or more nodes (default:current) - rm # Remove one or more nodes from the swarm - update # Update a node plugin: # --<< Plugins >>-- - create # Create a plugin from a rootfs and configuration. Plugin data directory must contain config.json and rootfs directory. - disable # Disable a plugin - enable # Enable a plugin - inspect # Display detailed information on one or more plugins - install # Install a plugin - ls # List plugins - push # Push a plugin to a registry - rm # Remove one or more plugins - set # Change settings for a plugin - upgrade # Upgrade an existing plugin secret: # --<< Secrets >>-- - create # Create a secret from a file or STDIN as content - inspect # Display detailed information on one or more secrets - ls # List secrets - rm # Remove one or more secrets service: # --<< Services >>-- - create # Create a new service - inspect # Display detailed information on one or more services - logs # Fetch the logs of a service or task - ls # List services - ps # List the tasks of one or more services - rm # Remove one or more services - rollback # Revert changes to a service's configuration - scale # Scale one or multiple replicated services - update # Update a service stack: # --<< Stacks >>-- - deploy # Deploy a new stack or update an existing stack - ls # List stacks - ps # List the tasks in the stack - rm # Remove one or more stacks - services # List the services in the stack swarm: # --<< Swarm >>-- - ca # Display and rotate the root CA - init # Initialize a swarm - join # Join a swarm as a node and/or manager - join-token # Manage join tokens - leave # Leave the swarm - unlock # Unlock swarm - unlock-key # Manage the unlock key - update # Update the swarm system: # --<< System >>-- - df # Show docker disk usage - events # Get real time events from the server - info # Display system-wide information - prune # Remove unused data trust: # --<< trust on Docker images (experimental) >>-- - key: # Manage keys for signing Docker images (experimental) - generate # Generate and load a signing key-pair - load # Load a private key file for signing - signer: # Manage entities who can sign Docker images (experimental) - add # Add a signer - remove # Remove a signer - inspect # Return low-level information about keys and signatures - revoke # Remove trust for an image - sign # Sign an image - view # Display detailed information about keys and signatures volume: # --<< volumes >>-- - create # Create a volume - inspect # Display detailed information - ls # List volumes - prune # Remove all unused volumes - rm # Remove volumes
Commands:
: $ docker [OP] [COMMAND] Show Version: $ docker version [OP] Show Info: $ docker info [OP] Image Search: $ docker search [OP] <IMAGE> Image Download: $ docker pull [OP] <REPOSITORY[:TAG]> Image list: $ docker images [OP] [REPOSITORY[:TAG]] Image create&start: $ docker run [OP] <IMAGE> [COMMAND] [ARG...] Command exec: $ docker exec [OP] <CONTAINER> <COMMAND> [ARG...] Container list: $ docker ps [OP] Container log: $ docker logs [OP] <CONTAINER> Containerに接続: $ docker attach [OP] <CONTAINER> Container create: $ docker create [OP] <IMAGE> [COMMAND] [ARG...] Container start: $ docker start [OP] <CONTAINER> Container restart: $ docker restart [OP] <CONTAINER> Container stop: $ docker stop [OP] <CONTAINER> Container delete: $ docker rm [OP] <CONTAINER> Container Info: $ docker inspect [OP] <CONTAINER> Image commit: $ docker commit [OP] <CONTAINER> [REPOSITORY[:TAG]] Image delete: $ docker rmi [OP] <IMAGE> Image build: $ docker build [OP] <PATH> Image tag: $ docker tag <REPOSITORY[:TAG]> Image history: $ docker history [OP] <IMAGE>
Dockerfile commands:
FROM <IMAGE:TAG> MAINTAINER <NAME> RUN CMD ["<COMMAND>"] EXPOSE ENV COPY ADD ENTRYPOINT [" "] VOLUME USER WORKDIR <PATH> ONBUILD