A platform for building,running and shipping applications. in a consistent manner so if your application works on your development machine it can run and function the same way on other machine.
Container: An isolated environment for running an application.
Container states – A container can be in one of four states: created,running, paused, exited, restarting.
Docker images are The blueprints of our application which form the basis of containers. We use docker pull command to download an image.
-
A standalone, executable package that can be run in a container.
-
A Docker image is a binary that includes all of the requirements for running a single Docker container, as well as metadata describing its needs and capabilities.
-
An image includes everything that is needed to run an application, including the application's executable code, any software on which the application depends, and any required configuration settings. You can build your own images (using a Dockerfile) or use images that have been built by others and then made available in a registry (such as Docker Hub).
-
To build an image from a Dockerfile you use the docker build command.
-
To run an image in a container you use the docker run command.
Containers - Created from Docker images and run the actual application. After downloading the image We create a container using docker run command. A list of running containers can be seen using the docker ps command.
A text document containing the commands to build a Docker image.
To build an image from a Dockerfile you use the docker build command.
#comments
FROM golang:alpine
ENV GO111MODULE=on
ENV BG_COLOR=skyblue
WORKDIR /opt/webapp
COPY . .
RUN go build
RUN go install -v ./...
EXPOSE 8180
CMD ["dockerapp"]
Syntax: docker build
docker build .
repository=, tage=
docker build . -t mateors/hello
repository=mateors/hello, tag=latest
docker build . -t mateors/hello:1
repository=mateors/hello, tag=1
docker build -f Dockerfile.dev -t helloWorld
repository=helloWorld, tag=latest
docker build -f Dockerfile.dev -t helloWorld:1
repository=helloWorld, tag=1
there are two commands to show the image list
- docker images
- docker image ls
docker images --help
docker images
docker image ls
docker history <imageName or ID>
docker image history <imageName or ID>
docker image prune
docker image rm <imageName or ID>
docker image remove <imageName or ID>
docker image rmi <imageName or ID>
docker image rmi -f <imageName or ID>
docker image rmi <imageName or ID> <imageName or ID> <imageName or ID>
docker history --help
docker history <imageName or ID>
docker image inspect --help
docker image inspect <imageName or ID>
- latest tag is just a label
- latest tag does not neccessarily mean it is the latest version of the image
- latest tag does not neccessarily reference the latest image
- Explicit tag to indentify what version you are running (
docker image tag <imageID> webapp:latest
)
docker build -t webapp .
clean build
docker images
to display all of our images
docker image tag
There are tow ways
- One way is tag an image while building it (
docker build -t webapp:2 .
) - the other way after the build (
docker image tag webapp:latest webapp:1
)
docker image tag <imageID> webapp:latest
updates tag after build (Explicitly)
docker image remove webapp:2
Login to hub.docker.com (if not registered yet please signup)
Navigate to https://hub.docker.com/repositories\
For publishing to docker hub tag
Syntax:docker image tag <imageName or ID> RepoPath:TAG
docker image tag 8d92 mateors/webapp:2
Now login from the command line using docker login command
docker login
or
winpty docker login
from gitbash terminal
docker build -t webapp:beta .
docker image tag webapp:beta mateors/webapp:beta
docker push mateors/webapp:beta
All possible commands are listed in the following google docs