Run a NGINX Container on Docker
The Nautilus DevOps team is conducting application deployment tests on selected application servers. They require a nginx container deployment on Application Server 1. Complete the task with the following instructions:
On Application Server 1 create a container named nginx_1 using the nginx image with the alpine tag. Ensure container is in a running state.
Steps
Lets run the following command to run a docker container:
sudo docker run -d --name nginx_1 -p 80:80 nginx:alpine
Good to Know?
Docker Container Basics
- Container: Running instance of Docker image
- Image: Read-only template for creating containers
- Lightweight: Share host OS kernel, faster than VMs
- Isolation: Process and filesystem isolation
Docker Run Options
- -d: Detached mode (run in background)
- –name: Assign custom name to container
- -p: Port mapping (host:container)
- -v: Volume mounting for persistent data
NGINX Alpine
- Alpine Linux: Minimal Linux distribution (~5MB)
- Security: Reduced attack surface
- Performance: Faster startup and lower resource usage
- Production: Ideal for production deployments
Container Management
- List:
docker ps (running), docker ps -a (all)
- Stop:
docker stop container-name
- Start:
docker start container-name
- Remove:
docker rm container-name