- Installation of docker can change or become more convenient on time being so I am not listing down installation steps here rather I am providing an official link for installation. Follow the steps there according to your system.
- Docker on Windows
- Docker on Mac
- Docker on Ubuntu Linux
- For Ubuntu Linux, if you are willing to install it with fewer efforts then follow this link. here you can install it using a script. there are other manual options also you can try if you are more interested in it.
Frequently used commands:-
docker build —
- To create an image from Dockerfile
- We have already gone through this command while creating an image through Dockerfile in 01.Docker Basics
- You can explore more option used for this command in this document
4. Ex — docker build -f Dockerfile -t MyWebApp:1.0 .
docker pull -
- To pull images from the docker hub.
- Ex- docker pull ubuntu: latest
- Where “latest” is the tag of that image. There can be many tags like ubuntu:16, ubuntu: bionic, etc.
docker run -
- To run the image. It first checks in the local space if that image is available or it will try to pull from docker-hub.
- Ex: docker run ubuntu: latest
docker ps -
- To checklist of containers
- “-a” option shows all containers some are running or some might be exited.
- Ex: docker ps -a
docker images -
- shows a list of images currently available locally
- ex: Dockers images
docker rm <container id>
1. for deleting container, you have to pass container id
docker rmi <image id> to delete image
Container Starting and stopping:-
- docker start — starts a container so it is running.
- docker stop — stops a running container.
- docker restart — stops and starts a container.
- docker pause — pauses a running container, “freezing” it in place.
- docker unpause — will unpause a running container.
- docker wait — blocks until running container stops.
- docker kill — sends a SIGKILL to a running container.
- docker attach — will connect to a running container.
- docker ps — shows running containers.
- docker logs — gets logs from the container.
- docker inspect — looks at all the info on a container (including IP address).
- docker events — gets events from containers.
- docker port — shows a public-facing port of the container.
- docker top — shows running processes in the container.
- docker stats — shows containers’ resource usage statistics.
- docker diff — shows changed files in the container’s FS.
Container import/ export :-
- docker cp — copies files or folders between a container and the local filesystem.
- docker export — turns container filesystem into tarball archive stream to STDOUT.
- docker exec — to execute a command in a container.
Commands related to images
- docker images — shows all images.
- docker import — creates an image from a tarball.
- docker build — creates an image from Dockerfile.
- docker commit — creates an image from a container, pausing it temporarily if it is running.
- docker rmi — removes an image.
- docker load — loads an image from a tar archive as STDIN, including images and tags.
- docker save — saves an image to a tar archive stream to STDOUT with all parent layers, tags & versions.
- docker history — shows the history of the image.
- docker tag — tags an image to a name (local or registry).
These are commands which we will be using till we reach an advanced stage. We will get some information about how to make a docker file if there are, multiple modules in the project like server and database.
There are two options for the same one is docker-compose. and another is using script. Let’s understand more in the next chapter.