Check the latest version of docker is installed using:
docker version
Run docker ps and docker run hello-world to ensure the daemon is working as expected
docker ps
docker run hello-world
Run a simple webserver in a container on your local machine
docker run -d -p 80:80 --name webserver nginx
In a web browser, go to http://localhost/
to bring up the home page.
Run docker ps while your web server is running to see details on the webserver container.
docker ps
The output should look something like this
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
56f433965490 nginx "nginx -g 'daemon off" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 443/tcp webserver
If you want to stop the webserver, type: docker stop webserver and start it again with docker start webserver
docker stop webserver
docker start webserver
To stop and remove the running container with a single command, type: docker rm -f webserver.
docker rm -f webserver