【docker】docker部署爬虫实战

醉酒当歌 提交于 2019-12-30 14:17:01

环境

系统:ubuntu18.04
docker:19.03.5

Docker概述

一、安装docker

1、卸载已安装的docker

 sudo apt autoremove docker
 
 sudo apt autoremove docker-engine
 
 sudo apt autoremove docker.io

2、执行自动安装docker的脚本

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

安装成功后出现:

Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea838
 Built:             Wed Nov 13 07:29:52 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea838
  Built:            Wed Nov 13 07:28:22 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
  
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker dell

Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.

此时,docker CE 的稳定(stable)版本已经安装在系统中。

3、新建docker用户组,并将当前用户加入

sudo groupadd docker
sudo usermod -aG docker 当前用户的用户名

4、设置docker开机自启动,并重启docker使配置生效

sudo systemctl enable docker
sudo systemctl start docker
sudo systemctl daemon-reload
sudo systemctl restart docker

5、验证docker的启动

docker run hello-world

出现如下信息说明启动成功:


Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

二、创建docker镜像

Docker日志默认存储位于:/var/lib/docker/containers/<container_id>/*.log

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!