Docker is a platform for building, running and shipping applications.
Docker is a tool designed to make it easier to create, deploy, and run applications by using containers.
Containers:
- An Isolated Environment for running an application
- Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.
- By doing so, thanks to the container, the developer can rest assured that the application will run on any other machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.
- The main objective of Containers is Consistent working of an application in all system.
- In a way, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they're running on and only requires applications be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application.
Checking the version
We can check the version of the docker using the following command.
docker version
Client:Cloud integration: 1.0.14Version: 20.10.6API version: 1.41Go version: go1.16.3Git commit: 370c289Built: Fri Apr 9 22:49:36 2021OS/Arch: windows/amd64Context: defaultExperimental: trueServer: Docker Engine - Community Engine: Version: 20.10.6 API version: 1.41 (minimum version 1.12) Go version: go1.13.15 Git commit: 8728dd2 Built: Fri Apr 9 22:44:56 2021 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.4 GitCommit: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e runc: Version: 1.0.0-rc93 GitCommit: 12644e614e25b05da6fd08a38ffa0cfe1903fdec docker-init: Version: 0.19.0GitCommit: de40ad0
This command give us the elaborate version of all the components of the docker.
In order to just get the version of the docker alone, we can use the following command.
docker -v
Which gives us a output similar to this,
Docker version 20.10.0, build 7287ab3
docker info
The docker info command displays system wide information.
docker info
Client:Context: defaultDebug Mode: falsePlugins:app: Docker App (Docker Inc., v0.9.1-beta3)buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)compose: Docker Compose (Docker Inc., 2.0.0-beta.1)scan: Docker Scan (Docker Inc., v0.8.0)Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 20.10.6 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 1 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc Default Runtime: runc Init Binary: docker-init containerd version: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec init version: de40ad0 Security Options: seccomp Profile: default Kernel Version: 5.4.72-microsoft-standard-WSL2 Operating System: Docker Desktop OSType: linux Architecture: x86_64 CPUs: 12 Total Memory: 6.08GiB Name: docker-desktop ID: XZ2G:J7PC:OMF5:M5WA:PMLW:6MDU:HUE5:T3KJ:5WN3:THN5:XOVI:IFYB Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8Live Restore Enabled: false
T
docker help
docker help will give all the commands that can be used in docker.
docker help
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default
"C:\\Users\\JARVIS\\.docker")
-c, --context string Name of the context to use to connect to the
daemon (overrides DOCKER_HOST env var and
default context set with "docker context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level
("debug"|"info"|"warn"|"error"|"fatal")
(default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default
"C:\\Users\\JARVIS\\.docker\\ca.pem")
--tlscert string Path to TLS certificate file (default
"C:\\Users\\JARVIS\\.docker\\cert.pem")
--tlskey string Path to TLS key file (default
"C:\\Users\\JARVIS\\.docker\\key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Management Commands:
app* Docker App (Docker Inc., v0.9.1-beta3)
builder Manage builds
buildx* Build with BuildKit (Docker Inc., v0.5.1-docker)
compose* Docker Compose (Docker Inc., 2.0.0-beta.1)
config Manage Docker configs
container Manage containers
context Manage contexts
image Manage images
manifest Manage Docker image manifests and manifest lists
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
scan* Docker Scan (Docker Inc., v0.8.0)
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
Run 'docker COMMAND --help' for more information on a command.
To get more help with docker, check out our guides at https://docs.docker.com/go/guides/
The docker help command can also be used to provide the provide usage and options available for any commands.
docker <command> --help
// For example
docker attach --help
The output will be:
Usage: docker attach [OPTIONS] CONTAINER
Attach local standard input, output, and error streams to a running container
Options:
--detach-keys string Override the key sequence for detaching a
container
--no-stdin Do not attach STDIN
--sig-proxy Proxy all received signals to the process
(default true)
docker images
This command list all the docker images.
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest c0cdc95609f1 7 hours ago 556MB
ubuntu latest 7e0aa2d69a15 2 weeks ago 72.7MB
ubuntu 18.04 4eb8f7c43909 2 weeks ago 63.1MB
The command to list all the docker images with only their id.
docker images -q
It will display all the image ids
c0cdc95609f1
7e0aa2d69a15
4eb8f7c43909
The docker pull is used to pull an image or repository.
docker pull <image or repository name>
Here is the Output
Using default tag: latest
latest: Pulling from library/ubuntu
345e3491a907: Pull complete
57671312ef6f: Pull complete
5e9250ddb7d0: Pull complete
Digest: sha256:cf31af331f38d1d7158470e095b132acd126a7180a54f263d386da88eb681d93
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest
docker rmi
The docker rmi is used to remove the image.
docker rmi <imagename>
To remove all the images:
docker rmi $(docker images -aq)
docker inspect
This return low level information about the docker objects.
docker inspect <name>
docker history
It shows the history of the image.
docker history <imagename>
docker run
This runs processes in an isolated container.
For example,
docker run --name ubuntu1 -it ubuntu /bin/bash
The --name option allows us to provide a name to the image and in the -i and -t allows us to run in interactive and allocate a tty for our process.
docker start
This command is used to start the container.
docker start <container name/id>
docker ps
This command lists all the containers.
docker ps
This command shows only the containers which are running. To list all the containers whether its running or not, the following command can be used.
docker ps -a
docker pause/unpause
This command is used to pause the container.
docker pause <container name/id>
Similarly, to un pause the following command can be used.
docker unpause <container name/id>
docker stop
Stops the specified containers.
docker stop <container name/id>
docker kill
Kills the specified containers.
docker kill <container name/id>
Comments
Post a Comment