5. open source container based technology
container allows developers to package up an
application,all the dependency that is required in the box
docker is written in Go.
9. CREATING THE FIRST CONTAINER
The most common way to create a container is by using
docker run command.
for example :
docker run --name test ubuntu:14.04 echo hello world
similarly,we can create a interactive container by
launching a bash shell inside it
docker run -it --name test1 ubuntu:14.04 /bin/bash
10. LISTING CONTAINER
we can list the container using docker ps command.
This will show only the running container.
for showing all the running and the stopped container,we
can use the -a attribute.
for example :
docker ps -a
11. STOPPING THE CONTAINER
we can stop the container using the following command.
docker stop <container>
This will stop the specified running container.
12. STARTING THE CONTAINER
To re-execute the process of a stopped container we can
use the following command.
docker start <container>
To attach to a running container we can use the following
command.
docker attach <container>
13. INSPECTING THE CONTAINER
To show very detailed information,in JSON format , about
container and its process execute
docker inspect <container>
Inspection is available in both stopped and running
container
14. READING A CONTAINER'S OUTPUT
Docker redirect's stdout and stderr of every container
both to current terminal and Docker's internal logs
docker logs <container>
15. RENAMING THE CONTAINER
To rename the container we can use the following
command.
docker rename <oldname> <newname>
16. REMOVING CONTAINERS
To remove the stopped container we can use the
following command.
docker rm <container>
use -f for force deletion.
To delete all the stopped containers at once.
docker rm $(docker ps -aq)
19. REMOVING IMAGES
To remove the selected image we can use the following
command.
docker rmi <ImageName>
To delete all the images at once,use
docker rmi $(docker ps -aq)
20. LOGIN TO DOCKER REGISTRY
Register or log in to a Docker registry server
docker login
21. PULLING THE IMAGE
To Pull an image or a repository from a Docker registry
server use the following command.
docker pull <Name:Tag>
22. PUSHING THE IMAGE
To push an image or a repository to the registry use the
following command.
docker push <Name:Tag>
23. LOGOUT FROM DOCKER REGISTRY
To logout from docker registry server
docker logout
24. VOLUME
A volume is a path in a container file system that is
actually backed by a path in host file system thus
allowind data sharing between containers and between
host and the containers.
docker run -it -v <Hostpath>:<containerPath>
<BaseImage>
25. COMMIT
Create a new image from a container's changes
docker commit [options] <CONTAINER>
[REPOSITORY[:TAG]]
26. CREATING THE IMAGE
Docker images can be created in 2 different ways:
By editing the Dockerfile command in the hostfile
system and executing the docker build command
By working in the container and saving the changes by
using docker commit command
27. BUILDING THE IMAGE VIA DOCKERFILE
The steps are simplified and standard:
Create a directory having a file named Dockerfile.
Edit the Dockerfile,according to related syntax.
Run the following command to build image from the
Dockerfile
docker build -t <ImageName:Tag> <directory of
Dockerfile>
30. DOCKER COMPOSE
Compose is a tool for defining and running multi-
container docker application.
With compose, we choose a compose file to configure our
application's service.
Then using a single command we create and start all the
services from our configuration.