Create root.txt File Inside Docker Container Using Nginx Server

Create and place a root.txt file inside the Nginx Docker container’s web root directory to make it accessible via the browser.

Dockerfile:

FROM nginx:alpine
COPY root.txt /usr/share/nginx/html/

Now create dokcer-compose.yml file.

nano docker-compose.yml
version: '3'
services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "80:80"

Build the Docker image.

docker-compose build

Run the Docker container.

docker-compose up -d

Last updated