Docker Quick Tips
Deleting all Images
Using the Docker Quick Start Terminal in Windows:
This will remove all the Docker images
Common Docker commands used everyday
Once you have a dockerfile you will most likely build it using:
Note that the .
refers to the current directory, and hence, your Dockerfile must be present where you are running this command.
Afterwards, you may want to run the build:
Here we are using optional flag of -p
or --publish
which specifies which port to listen to for incoming request,
and which port to direct it to for outgoing request. This is useful when deploying webapps.
The internal port will be the port you have exposed in the Dockerfile using EXPOSE <portnumber>
command.
To show running processes
To kill a process, use docker ps
to get the image_id
and use
Further, to remove an image, you can use:
Note that this will force remove any running containers as well (due the -f
flag)
Docker Images for Python
- Use Alpine for Python apps that have very limited dependencies, and the docker container size is to be kept at a bare minimum.
- Use the full Image for python (such as
FROM python-3.8.3
) when you want to install something like Pandas/Numpy/SciPy etc.
Remove volumes from Docker
List all volumes using:
Remove volume named "volume_abc" by using volume rm command
Start containers using docker compose
To start all containers. It will also build the images if they are not present by reading the docker-compose.yml file.