Skip to content

Instantly share code, notes, and snippets.

@gabrieljcs
Created August 6, 2018 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrieljcs/7f7ac373092930b71089bccf65a7962a to your computer and use it in GitHub Desktop.
Save gabrieljcs/7f7ac373092930b71089bccf65a7962a to your computer and use it in GitHub Desktop.
Simple nginx quick setup using Docker (good for references)

Docker quick start

A simple nginx quick setup using Docker

Install Docker and add your user to the Docker group

# apt-get install docker.io
# groupadd docker
# usermod -aG docker $USER

Create a webpage in your system (outside any container)

$ mkdir ~/html
$ echo "<html><h1>Hello from Docker! :)</h1></html>" > ~/html/index.html

Start Docker daemon

# systemctl start docker

Need to temporarily disable selinux

# setenforce 0

Run nginx through Docker and link to local webpage previously created

# docker run -d -p 8080:80 -v ~/html:/usr/share/nginx/html nginx

Access localhost:8080 from a browser to see your page.

To kill the container, first get its id with

# docker container ls

Then, kill with

# docker kill <id>

The first three characters from the id are enough, or the name.

To attach bash to a Docker container, in case of troubleshooting

# docker exec -it <id> bash

Don't forget to reenable selinux after everything is done!

# setenforce 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment