This is a simple static website served by nginx and hosted by a docker container
Running the hello-world container image
$docker run --name hello hello-world
Verify running containers
$docker ps
Verify all containers
$docker ps -a
Listing available images
$docker images
Removing a container
$docker rm container_name
Removing a image
$docker rmi hello-world
Connecting terminal to running container
$docker rmi hello-world
Exit bash without closing the container (detach)
Ctrl+p
then Ctrl+q
Connect bash to running container (attach)
$docker attach container_name
Restart an existing container after it exited and your changes are still there
$docker start -i $(docker ps -q -l)
from: https://stackoverflow.com/questions/21928691/how-to-continue-a-docker-container-which-has-exited
Create a simple nginx-compatible linux image
$docker run --name myimg ubuntu:18.04
Deleting it
$docker rm myimg
Ok, now lets make it interactive so we can install a web server
$docker run -it --name mysite ubuntu:18.04
Install NGINX inside it
$apt-get update
$apt-get install -y nginx
We can also do it programmatically by building the dockerfile
content.
(this will run the scripted routines in the dockerfile
inside this folder)
$docker build --tag ngxr:v1 <path>
Start NGINX
$/etc/init.d/nginx start
Detach and inspect your container's IP address (Try it on your browser!)
$docker inspect nginx-site1
Nice container, lets make it an image so we can re-use it
$docker commit nginx-site1 ngxr
building the docker file without network bind
$docker run -it --name nginx-site nginx:1.0 bash
run the container and bind it to your local network port (This is called EXPOSE and can only be done when creating it!!!)
$docker run -it -p 8080:80 --name nginx-site2 nginx:1.0 bash
start nginx
$/etc/init.d/nginx start
Don't forget to have fun :-)
docker helpful insights: https://github.com/vconrado/mc9-worcap2018
html template source: https://github.com/toidicode/template