docker installation and basic use

Installation prerequisites

1, the kernel must Linux 3.8 or higher version of the kernel
2, 64-bit computer architecture CPU
3, the kernel must support a suitable storage drive (typically Device Mapper or the AUFS)
. 4, the kernel must support and open cgroup and namespace (namespace) function

installation steps

1, apt docker official version of the library may be relatively old, so uninstall the old version may exist: sudo apt-GET-the Remove Docker Docker Docker-ce docker.io Engine
2, an index update apt package: sudo apt-GET Update
3 installation Docker: APT-GET install docker.io
4, verify that the installation is complete: sudo docker info

 

Basic Commands

All containers and returns the number of mirrors, and performs driving Docker storage drives used, and the basic configuration of Docker

# Returns the number of all containers and mirroring, and performs driving Docker storage drives used, and the basic configuration Docker 

docker info   

  

Creating an interactive container

# Create interactive container 
Docker RUN Ubuntu -i -t / bin / the bash 

# -i ensure that the container is a standard input interactive shell 
# -t assigns a pseudo-tty terminal 
# provides interactive operation of a container shell. 
# First docker will check whether there is local mirroring ubuntu, if not local, it will connect to the official maintenance Docker Hub Registry, to see if there is a mirror, the mirror once found it will download the image and save it to the local host machine . 
# Finally, we tell Docker in what order to run the new container, / bin / bash command starts a Bash shell

  

Named to the container and start

docker run --name container_name -i -t ubuntu /bin/bash

 

Start has stopped running container

docker start container_name

  

Reattached to the container session

docker attach container_name 
after container_name # boot attached to the container, the container is reattached to the session

  

Docker Exit to return to the host

exit 
performed after exit # adhered to the container, this container will be stopped, because in operation, the container is in the operating state will be appropriate only if the specified / bin / bash command

  

View a list of all containers in the current system

docker ps -a 

  

 View a list of the current system running container

 docker ps  

  

Create a guardian container

RUN -it -d Ubuntu Docker / bin / bash 
# long-running vessel, -d parameter causes Docker containers will be placed in the background.

  

Monitoring logs

100 -f container_name logs --tail Docker 
 # container_name log monitoring

  

View inside the container running processes

docker top container_name

  

Delete container

docker rm container_name

  

Mirror warehouse

Lists all the local mirror

docker images

  

Mirror Pull

docker pull ubuntu: 12.04 
behind a colon TAG version #

 

Operating a mirror with a label

docker run -it ubuntu:12.04 /bin/bash

  

Find a mirror on the docker hub

docker search the repository name 
# docker hub There are two types Warehouse: user warehouse (docker user-created), the top-level warehouse (docker internal personnel management) 
# user repository name consists of a user name and warehouses names of two parts, such as idktp / myImage. 
# top warehouse value contains the name of the warehouse

  

Login Docker hub

docker login

  

 

 

 

 

 

Delete local mirror

docker rmi ubuntu 

  

 

Guess you like

Origin www.cnblogs.com/idontknowthisperson/p/11264177.html