This is an example of using Docker. Look inside Dockerfile
, it's based on the official nginx image.
Ensure that your PC have Docker installed.
- Clone this repo
git clone [email protected]:yesnik/docker_hello.git
- Bulid an image with the repo name
docker_hello
and tag1.0
cd docker_hello
docker build -t docker_hello:1.0 .
- Ensure that the image has been created
docker images
- Create container based on our image
docker run --name docker_hello_container -d -p 8080:80 docker_hello:1.0
Params:
--name docker_hello_container
- name of the created container-d
- detaches from the container, running it in the background-p 8080:80
- maps network ports. Your host's port 8080 will be mapped to container's 80 portdocker_hello:1.0
- image's name
- Visit page: http://127.0.0.1:8080/. You'll see the message from
index.html
file.
- Look at the running containers
docker ps
- Connect to the container and use bash
docker exec -it docker_hello_container bash
Flag -it
attaches us to an interactive tty in the container.
-
To exit container press
Ctrl + D
-
Stop the container
docker stop docker_hello_container
- Remove the container
docker rm docker_hello_container
- Ensure that the container has been deleted
docker ps -a
You won't see docker_hello_container
in the list.
In this repo we have created self-contained web server that could easily serve many web documents. We can deploy it on any server with Docker.