Browse Source

docker 1

master
test2 5 years ago
parent
commit
909da6ca6e
  1. 162
      DockerSwarm/Intro-Cloud.adoc

162
DockerSwarm/Intro-Cloud.adoc

@ -126,6 +126,168 @@ Origin:
https://www.nirmata.com/2018/01/15/orchestration-platforms-in-the-ring-kubernetes-vs-docker-swarm
== Docker
=== Images
In Docker, everything is based on Images. An image is a combination of a file system and parameters.
==== Dockerfile
A Dockerfile is a simple text file that contains a list of commands that the Docker client calls while creating an image. It's a simple way to automate the image creation process. The best part is that the commands you write in a Dockerfile are almost identical to their equivalent Linux commands. This means you don't really have to learn new syntax to create your own dockerfiles.
.Dockerfile
[source,sh]
----
FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -y && \
apt-get -y install gcc && \
rm -rf /var/lib/apt/lists/*
----
==== docker build
.docker build
[source,sh]
----
docker build -t ImageName:TagName dir
Options
-t − is to mention a tag to the image
ImageName − This is the name you want to give to your image.
TagName − This is the tag you want to give to your image.
Dir − The directory where the Docker File is present.
----
.docker build example
[source,sh]
----
docker build –t myimage:0.1 .
----
==== Displaying Docker Images
To see the list of Docker images on the system, you can issue the following command.
.docker images
[source,sh]
----
docker images
----
This command is used to display all the images currently installed on the system.
**Output:**
- TAG − This is used to logically tag images.
- Image ID − This is used to uniquely identify the image.
- Created − The number of days since the image was created.
- Virtual Size − The size of the image.
=== Containers
Containers are instances of Docker images that can be run using the Docker run command. The basic purpose of Docker is to run containers.
==== Running a Container
Running of containers is managed with the Docker run command. To run a container in an interactive mode, first launch the Docker container.
.run docker image
[source,sh]
----
docker run –it myimage /bin/bash
----
==== Listing of Containers
One can list all of the containers on the machine via the docker ps command. This command is used to return the currently running containers.
.run docker image
[source,sh]
----
docker ps
----
==== Display the running processes of a container
With this command, you can see the top processes within a container.
Syntax
.docker top
[source,sh]
----
docker top ContainerID
Options
ContainerID − This is the Container ID for which you want to see the top processes.
----
==== Stop a running container
This command is used to stop a running container.
.docker stop
[source,sh]
----
docker stop ContainerID
Options
ContainerID − This is the Container ID which needs to be stopped.
----
==== Attach a running container
This command is used to attach to a running container.
.docker
[source,sh]
----
docker attach ContainerID
Options
ContainerID − This is the Container ID to which you need to attach.
----
==== Delete container
This command is used to delete a container.
.docker rm
[source,sh]
----
docker rm ContainerID
Options
ContainerID − This is the Container ID which needs to be removed.
----
:hardbreaks:
{empty} +

Loading…
Cancel
Save