Useful Docker commands

List Docker instances

Run a Docker instance and make sure ports are mapped:

sudo docker run -p 1025:1025 -p 8025:8025 ae2e

Run a Docker instance and randomly assign port mappings:

sudo docker run -P ae2e

List Docker images:

sudo docker image ls

Show running Docker processes:

sudo docker ps

Start Docker in current directory:

docker up .

Kill a Docker container:

sudo docker kill a538

Reference:

https://docs.docker.com/engine/reference/builder/#expose

“The EXPOSE instruction does not actually publish the port. It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published. To actually publish the port when running the container, use the -p flag on docker run to publish and map one or more ports, or the -P flag to publish all exposed ports and map them to high-order ports.”

Share this article

Leave a Reply

Your email address will not be published.

Scroll to Top