Docker is a software available since 2013 that among other features performs operating-system-level virtualization also known ascontainerization
Docker offer the following features:
docker pull[1],docker push). By default docker hub but you can specify any other registry.You can read official Docker documentation about installing Docker on your system:https://docs.docker.com/install/.
On macOS you can follow official documentationhttps://docs.docker.com/docker-for-mac/install/ which requires to create and account to download installer. You can also try:brew cask install docker or try to followhttps://pilsniak.com/how-to-install-docker-on-mac-os-using-brew/ instructions:
brew install dockerdocker-compose docker-machine(to install docker and docker-compose)brew cask install virtualboxdocker-machine create --driver virtualbox defaultdocker-machine lsdocker-machine env defaulteval $(docker-machine env default)docker run hello-world (will pull hello-world image and run it on docker)On Ubuntu:snap install docker
Following binaries will be installed:docker-init,docker-proxy,docker anddockerd
Once installed the Dockerdaemon, called"dockerd" should be running. You can also rundocker run hello-world to verify docker correct installation.
/etc/docker/daemon.jsonUse:docker version[2] to check your version.You can download Docker CE source code from GitHub[3].
You can read official docker command line documentation inhttps://docs.docker.com/engine/reference/commandline/docker/. Before being able to run docker commands you will have to install Docker on your machine.
Some typical task using containers:
docker run hello-worldYou will see some message similar to this one:
Unable to find image 'hello-world:latest' locallylatest: Pulling from library/hello-worldca4f61b1923c: Pull completeDigest: sha256:97ce6fa4b6cdc0790cda65fe7290b74cfebd9fa0c9b8c38e979330d547d22ce1Status: Downloaded newer image for hello-world:latestHello from Docker!This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID: https://cloud.docker.com/For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
docker run -it alpine shdocker buildDockerfile[4]:docker build -f /path/to/a/Dockerfile .docker createdocker build --tag mediawiki:1.27 . (you can use -t or --tag)docker run --name wikiFGA -p 0.0.0.0:9090:80 -d mediawiki:1.27docker start CONTAINER_ID OR CONTAINER_NAME. See alsodocker run and differences[5].docker stop container_iddocker ps -a:https://docs.docker.com/engine/reference/commandline/ps/docker container ls -a. See alsodocker-compose psdocker exec[10] -it <my_container_name> bashdocker exec -it <my_container_name> shdocker start $(docker ps -a -q -f status=exited)docker restart $(docker ps -aq) previouslydocker restart $(docker ps -q)-a all -q quiet[11]
See also:docker compose anddocker stack
docker images[13],docker image ls (both commands seems to perform the same action, note it is image instead of images)docker info | grep "Docker Root Dir"[14]docker image rm[15]. See also:docker rm CONTAINERdocker network lsdocker network inspectdocker --link[16] docker run -it --cpus=".5" docker_image /bin/bashdocker info. Seehttps://docs.docker.com/install/linux/linux-postinstall/ anddocker-compose resource limitation example:DevOps/Docker/docker compose/Version 3 resoucesYou will be using mainly the following commandsdocker login,docker logout,docker pull anddocker push. Docker registry allow to configure notifications.[17]. Docker has a public repository called Docker Hub and cloud providers offer repositories services such as AWS Elastic Container Registry (ECR).
docker versionhttps://docs.docker.com/engine/reference/commandline/version/docker infohttps://docs.docker.com/engine/reference/commandline/info/docker statsdocker system infohttps://docs.docker.com/v17.12/edge/engine/reference/commandline/system_info/docker system eventshttps://docs.docker.com/v17.12/edge/engine/reference/commandline/system_events/docker system df docker top [CONTAINER_NAME or CONTAINER_ID]https://docs.docker.com/engine/reference/commandline/top/docker inspect CONTAINER_ID|IMAGE_ID[18]https://docs.docker.com/engine/reference/commandline/inspect/ also available for: container, image, volume, network, node, service, or taskdocker images,docker images -qdocker image inspect[19]docker image ls ordocker image ls --no-truncdocker run[20] IMAGE|IMAGE_ID:https://docs.docker.com/engine/reference/run/docker start CONTAINER_ID|CONTAINER_NAME:https://docs.docker.com/engine/reference/commandline/start/docker stop CONTAINER_ID|CONTAINER_NAME:https://docs.docker.com/engine/reference/commandline/stop/docker restart CONTAINER_ID|CONTAINER_NAME:https://docs.docker.com/engine/reference/commandline/restart/docker swarm[21]docker nodesdocker system prune -a remove unused and dangling images. Therefore any images being used in a container, whether they have been exited or currently running, will NOT be affected.[22]docker volume:https://docs.docker.com/engine/reference/commandline/volume/docker volume ls:https://docs.docker.com/engine/reference/commandline/volume_ls/docker inspect -f 'Template:.Mounts' CONTAINER_NAME[23]docker volumes pruneDocker support logging to format or different platforms, such as, json-file, syslog, journald, gelf, fluentd, awslogs, splunk, etwlogs, gcplogs and logentries.[24]
docker run -it --log-drive LOG_METHOD CONTAINER_IDdocker inspect -f 'Template:.HostConfig.LogConfig.Type' CONTAINER_IDdocker inspect -f 'Template:.HostConfig.LogConfig' CONTAINER_IDdocker logs CONTAINER_NAME_OR_ID (Docker Community Engine only support: local, json-file andjournald)docker logs CONTAINER_NAME_OR_ID 2>&1 | grep "STRING_TO_SEARCH" (You will need to redirect outputs to be able to grep output)[25]docker start anddocker run:https://stackoverflow.com/questions/34782678/difference-between-running-and-starting-a-docker-container. See alsorunC