Docker is a platform that allows developers to easily package and distribute their applications as containers. Containers are a lightweight and portable way of packaging software, and they allow developers to run the same code on different environments without compatibility issues. Docker provides a simple and consistent way of packaging, shipping, and running applications, making it easy for developers to build, test, and deploy their applications.

Here are some common Docker commands and examples of their usage:

·         docker run: used to run a new container. For example, docker run -d --name my-nginx -p 80:80 nginx will run a new container named "my-nginx" using the "nginx" image, running in detached mode and mapping the host port 80 to the container port 80.

·         docker ps: used to list running containers. For example, docker ps will list all running containers on the host.

·         docker images: used to list images. For example, docker images will list all images on the host.

·         ·  docker stop: used to stop a running container. For example, docker stop my-nginx will stop the running container named "my-nginx".

·         ·  docker rm: used to remove a container. For example, docker rm my-nginx will remove the container named "my-nginx".

·         ·  docker pull: used to pull an image from a registry. For example, docker pull nginx will pull the "nginx" image from the default registry.

·         ·  docker push: used to push an image to a registry. For example, docker push my-image will push the "my-image" image to the default registry.

·         ·  docker build: used to build an image from a Dockerfile. For example, docker build -t my-image . will build an image named "my-image" using the Dockerfile in the current directory.

·         ·  docker exec: used to run a command in a running container. For example, docker exec -it my-nginx bash will open a bash shell in the running container named "my-nginx".

Previous Post Next Post