I had a small task - run container with parameters:
- Name is
web
- Image is
nginx:latest
- The container must be available on port
9099
- The
/var/log/nginx
directory inside the container must be mounted to the/data/nginx/logs
directory on the host system - When starting the container, the environment variable
logging
=true
should be added
Complete instruction for starting the container:
docker run -d --name web -p 9099:80 -v /data/nginx/logs:/var/log/nginx \
-e logging=true nginx:latest
Explanation:
- docker run - start container
- -d - detached mode
- –name web - set name
- -p 9099:80 - port forwarding - 9099 is host’s port, 80 is container’s port
- -v /data/nginx/logs:/var/log/nginx - mount directory, analog:
--mount type=mount,src=/data/nginx/logs,dst=/var/log/nginx
- -e logging=true - set environment variable
- nginx:latest - nginx is image, latest is tag(sometimes version)