Getting Started with Docker Commands

Share
Cover illustration

Once Docker is set up on your system, you can interact with it through simple commands. Here are a few core Docker commands to get you started:

Pull an Image

docker pull [image]

This fetches an image from Docker Hub

Build an Image

docker build -t [image_name] .

This command builds a Docker image from a Dockerfile.

Run a Container

docker run -d -p [host_port]:[container_port] [image]

This command runs a container and maps a local port to a port in the container.

List Running Containers

docker ps

This lists all running containers.

Stop Containers

docker stop [container_id]

This stops a running containers.

Remove a container

docker rm [container_id]

This command will remove a stopped container.

Read more