Menu

Docker for Beginners: Build, Run, and Troubleshoot Your First Container
📰

Docker for Beginners: Build, Run, and Troubleshoot Your First Container

DEV Community: docker·Piyush Pandit·about 6 hours ago
#gUA7l7PE
#devtodocker#devto#dev#docker#nginx
Reading 0:00
15s threshold

Docker for Beginners: Build, Run, and Troubleshoot Your First Container

Docker is one of the most useful tools for developers and IT professionals who want to run applications in consistent, isolated environments.

In this tutorial, we'll create a basic container, build our own Docker image, and explore a few essential troubleshooting commands.

1. Check Your Docker Installation

First, confirm Docker is installed and available:

docker --version docker info

Enter fullscreen mode

Exit fullscreen mode

If the Docker daemon isn't running, docker info may display a connection error.

2. Run Your First Container

Start an Nginx web server:

docker run -d --name my-nginx -p 8080:80 nginx:alpine

Enter fullscreen mode

Exit fullscreen mode

What this command does:

-d runs the container in the background.

--name assigns a readable name.

-p 8080:80 maps your computer's port 8080 to port 80 inside the container.

nginx:alpine specifies the image to use.

Open http://localhost:8080 in your browser.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.