Last active
November 6, 2019 19:05
-
-
Save jpigree/1dc4a606a3bba992feac757463369675 to your computer and use it in GitHub Desktop.
demo docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get image ubuntu:16.04 from Docker's registry | |
docker pull ubuntu:16.04 | |
# Run "cat /etc/os-release" into container spawned from image ubuntu:16.04 | |
docker run ubuntu:16.04 cat /etc/os-release | |
cat /etc/os-release | |
# Show all containers | |
docker ps -a | |
# Run interactive bash into container spawned from image ubuntu:16.04 | |
docker run -it ubuntu:16.04 | |
<Ctrl-d> | |
# Create a helloworld script | |
cat >helloworld <<EOF | |
#!/bin/sh | |
echo "helloworld" | |
EOF | |
chmod +x helloworld | |
# Create a Dockerfile which includes the helloworld script into an ubuntu | |
cat >Dockerfile <<EOF | |
FROM ubuntu:16.04 | |
ADD helloworld / | |
CMD [ "/helloworld" ] | |
EOF | |
# Build the image | |
docker build -t helloworld . | |
# Run a container from the helloworld image | |
docker run helloworld | |
# Run an Nginx webserver with port 80 bound to host 8080 | |
docker run --name nginx -d -p 8080:80 nginx:1.16 | |
docker ps | |
curl http://localhost:8080 | |
docker stop nginx | |
docker ps | |
docker ps -a | |
docker rm nginx | |
# Safe Docker cleanup | |
docker system prune |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment