01 docker introduction

1, docker Profile

docker is a new approach to virtualization. Often a very complicated installation and deployment, use docker can be done quickly.
I would like to use the analogy maven, maven an important function is to manage jar package, we can download a maven jar package through our own program can also be labeled jar package upload for others to download. We put the above sentence maven replaced docker, the jar package into service, it becomes the role of docker: docker us through a download service, our services can also upload your own for others to use.

2, key concepts

docker to a few key concepts: Mirror, container, warehouse.

  • Mirroring is fixed, there is no start of the service, an operating system can be as large as small as a mysql.
  • Mirrored boot up, it becomes a container, the container provides services outside. In the case of a mirror port does not conflict, you can start several good container. Good container can be labeled as a mirror, or to let others use the complete system migration [let others use essentially a system migration]. Each container is isolated from each other to ensure the safety of the platform. The container can be seen as a simple version of the Linux environment (including root privileges, process space, user space and cyberspace, etc.) and running within the application.
  • Warehouse (Repository) is a centralized place to store the image file. Warehouse is divided into two forms of public warehouses (Public) and private warehouse (Private). The biggest public warehouse Docker Hub, store a huge number of images available for users to download. Of course, users can also create a private warehouse within the local network.

3, installation

Docker CentOS version supports the following:

  • CentOS 7 (64-bit)
  • CentOS 6.5 (64-bit) or later
    herein to workstation centos7 64 for example, mounting docker [Note: the workstations contains vast necessary data dependencies, and therefore installation is very simple]:
# 安装
yum -y install docker-io
# 启动
service docker start
# 查看状态
service docker status

4, replace the mirror, accelerate downloads

we /etc/docker/daemon.json

{

"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
#保存、重启
service docker restart

5, basic commands, for example to redis

#查看镜像
docker images
#删除镜像
docker rmi 镜像id
#查看容器
docker ps
#删除容器
docker rm 容器id
#搜索mysql镜像
docker search redis
#获取mysql镜像
docker pull redis
#启动redis
docker run -p 6379:6379 --name myredis redis
#进入redis环境
docker exec -it myredis bash
#将容器打成镜像
docker commit 容器id/名称  myredis1
#将镜像打成tar包
docker save -o myredis1.tar myredis1
#将tar包解成镜像
docker load -i myredis1.tar
后面,我们将把常用的服务都采用docker安装一番。

Guess you like

Origin www.cnblogs.com/alichengxuyuan/p/12581357.html