DEV Community

Janak Shrestha
Janak Shrestha

Posted on

Deploy Nginx Container on Application Server

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.


Step-by-Step Instructions

1. SSH into Application Server 1

ssh steve@stapp01
Enter fullscreen mode Exit fullscreen mode

(Enter the password when prompted)


2. Switch to root or use sudo

sudo su -
Enter fullscreen mode Exit fullscreen mode

or prefix all commands with sudo


3. Verify Docker is installed and running

docker --version
sudo systemctl status docker
Enter fullscreen mode Exit fullscreen mode

If Docker isn't running, start it:

sudo systemctl start docker
sudo systemctl enable docker
Enter fullscreen mode Exit fullscreen mode

4. Pull the nginx image with alpine tag

sudo docker pull nginx:alpine
Enter fullscreen mode Exit fullscreen mode

5. Create and run the container named nginx_1

sudo docker run -d --name nginx_1 nginx:alpine
Enter fullscreen mode Exit fullscreen mode

Explanation of options:

  • -d : Run container in detached mode (background)
  • --name nginx_1 : Assign the name "nginx_1" to the container
  • nginx:alpine : Use the nginx image with alpine tag

6. Verify the container is running

sudo docker ps
Enter fullscreen mode Exit fullscreen mode

You should see output similar to:

CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS     NAMES
xxxxxxxxxxxx   nginx:alpine   "/docker-entrypoint.…"   x seconds ago   Up x seconds             nginx_1
Enter fullscreen mode Exit fullscreen mode

7. Additional verification (optional)

Check container details:

sudo docker inspect nginx_1
Enter fullscreen mode Exit fullscreen mode

Test if nginx is working (get container IP):

sudo docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nginx_1
Enter fullscreen mode Exit fullscreen mode

Complete One-Line Command

If you want to do it all at once (after SSH into stapp01):

sudo docker run -d --name nginx_1 nginx:alpine
Enter fullscreen mode Exit fullscreen mode

Summary of Commands

# SSH to App Server 1
ssh steve@stapp01

# Run the container
sudo docker run -d --name nginx_1 nginx:alpine

# Verify
sudo docker ps
Enter fullscreen mode Exit fullscreen mode

Verification Checklist

  • [ ] Container name is nginx_1
  • [ ] Image used is nginx:alpine
  • [ ] Container is in running state (Up status in docker ps)

Top comments (0)