A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.
docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
docker run andersbogsnes/cowsay hello world
-------------
< hello world >
-------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
docker run -d \
-e ACCEPT_EULA=Y \
-e MSSQL_SA_PASSWORD=Secure.Password1234 \
-p 1433:1433 \
mcr.microsoft.com/mssql/server:2019-latest
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
736c8af768c3 mcr.microsoft.com/mssql/server:2019-latest "/opt/mssql/bin/perm…" 25 seconds ago Up 24 seconds 0.0.0.0:1433->1433/tcp interesting_kalam
# Create a simple webpage echo "
Hello world
" >> index.html# Run an nginx container docker run -d \ -v ${PWD}/index.html:/usr/share/nginx/html/index.html:ro \ -p 8080:80 \ nginx
A Blueprint for a docker container
Described in a Dockerfile and the result of docker build
A running instance of an Image
The result of a docker run
A place to store Docker Images.
Default is Dockerhub - companies run their own registries such as Docker Trusted Registry aka DTR
# The python maintainers have already defined an image
# with python installed. I want to build on top of that
FROM python:3.9-slim
# Copy files from my local filesystem into the container
COPY my_code.py my_code.py
# Run an arbitrary command
RUN echo "This is executed when building this image"
# What command should my image run by default?
CMD ["echo", "This is executed when I run the image"]
docker build -t test_image .
docker images
docker run test_image
docker run test_image python my_code.py