~/Docker Basics for Lazy Developers
Dec 14, 2020
Docker is a tool to run applications in isolated environments called containers. It eliminates the pain of installing dependencies.
Install Docker by following the official guide.
Common commands:
-
Pull an image
1
docker pull nginx
-
Run a container
1
docker run -d -p 80:80 nginx
This starts an Nginx web server on port 80.
-
See running containers
1
docker ps
-
Stop a container
1
docker stop <container_id>
-
Remove a container
1
docker rm <container_id>
To make your own image, create a Dockerfile:
Then build and run:
The advantage of Docker is that your app will run the same everywhere, quick to set up and clean up. More at the Docker documentation.