独书先生 Menu

Viewing all items for tag Docker

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

问题

在WSL(Windows Subsystem for Linux )中运行docker version的时候,终端最后一行报错了

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

表明docker并没有正常启动,基本上就是要重启下docker就可以。

解决

小编的WSL安装的是Ubuntu系统,使用命令三成功启动docker,不熟悉Linux的话,你可以依次尝试以下命令。

  1. 命令一
systemctl start docker
  1. 命令二
sudo dockerd

dockerd 是 docker 容器的守护程序服务,因为它不在后台运行,我们无法采取与服务相关的任何操作,需要重新启动。

  1. 命令三
sudo service --status-all 
sudo service docker start

总结

以上就是小编在使用docker的过程中总结的一点经验,更多docker学习欢迎关注我的更新。

参考

centos下安装 docker, git, node, python环境

1. git

yum install git

2. docker

centos下

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

或者参考docker-ce安装

3. node

1. install latest nvm

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

if no any response,try curl:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

v0.35.3 is latest version currently i use, change the version if you need.learn more aboutnvm

if you get error

curl: (7) Failed connect to raw.githubusercontent.com:443; Connection reset by peer

just try open the https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh in browser,download install.sh file manually, then upload to your server, tap sudo bash install.sh manually.

2. solve commond not found

source ~/.nvm/nvm.sh

3. install node v12.X latest version

nvm install 12

4. check node version

node -v

4. python 3

udo yum install yum-utils
sudo yum-builddep python
curl -O https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tgz
tar xf Python-3.8.3.tgz
cd Python-3.8.3
./configure
make
sudo make install
alias python='/usr/local/bin/python3.8' #edit python command python3

windows docker 部署gogs / mysql / yapi / mongo

windows docker 部署gogs / mysql / yapi / mongo

environment

  1. docker for windows desktop
  2. docker configuration
{
  "registry-mirrors": [
    "http://hub-mirror.c.163.com",
    "https://registry.docker-cn.com"
  ],
  "insecure-registries": [],
  "debug": true,
  "experimental": false
}

gogs and mysql service

gogs and mysql network

docker network create --subnet 172.21.0.0/16 gogs_network

mysql

docker run --name my-mysql -p 3306:3306 -v C:/software/mysql:/var/lib/mysql --net gogs_network --ip 172.21.0.3 -e MYSQL_DATABASE=gogsdb -e MYSQL_USER=gogsuser -e MYSQL_PASSWORD=gogspwd -e MYSQL_ROOT_PASSWORD=gogspwd -e MYSQL_ALLOW_EMPTY_PASSWORD='yes' -d mysql

gogs

docker run --name my-gogs -p 1001:22 -p 1002:3000 -v C:/software/gogs/data:/data --net gogs_network --ip 172.21.0.2 gogs/gogs

yapi and mongo service

yapi and mongo network

docker network create --subnet 172.22.0.0/16 yapi_network

start mongo

docker volume create --name mongodata
docker volume create --name mongoconfigdb

docker run --name my-mongo -p 27017:27017 -v mongodata:/data/db -v mongoconfigdb:/data/configdb --net yapi_network --ip 172.22.0.3 -d mongo:4 --auth

mongo setting

# into mongo container
docker exec -it my-mongo mongo admin

# set admin user (root)
db.createUser({ user: 'admin', pwd: 'admin123456', roles: [ { role: "root", db: "admin" } ] });

# auth admin user
db.auth("admin", "admin123456")

# restart mongo
docker restart my-mongo

# into mongo container again
docker exec -it my-mongo mongo -u admin -p admin123456 --authenticationDatabase admin

# create yapi database
use yapi

# set yapi user
db.createUser({ 
    user: 'yapi', 
    pwd: 'yapi123456', 
    roles: [
        { role: "dbAdmin", db: "yapi" },
        { role: "readWrite", db: "yapi" } 
    ]
});

# auth yapi user
db.auth("yapi", "yapi123456")

yapi

docker build -t yapi .
docker run --name my-yapi -p 1003:3000 -p 1004:9090 -v C:/software/yapi/my-yapi:/my-yapi --net yapi_network --ip 172.22.0.2 -d yapi sh -c "yapi server"

deploy

open http://localhost:1004/ to deploy,get account:”admin@admin.com”, password:”ymfe.org”

change command restart serve

docker stop my-yapi
docker rm my-yapi
docker run --name my-yapi -p 1003:3000 -p 1004:9090 -v C:/software/yapi/my-yapi:/my-yapi --net yapi_network --ip 172.22.0.2 -d yapi sh -c "node my-yapi/vendors/server/app.js"

open http://localhost:1003/ to use

refer

https://hub.docker.com/_/mongo
https://www.cnblogs.com/woshimrf/p/docker-install-yapi.html
https://github.com/Ryan-Miao/docker-yapi
https://www.cnblogs.com/lori/p/7897003.html
https://segmentfault.com/q/1010000006128749

阿里云服务器如何配置docker镜像加速器

购买阿里云服务器后,安装docker镜像会比较慢,这时候通常可以使用阿里云的docker镜像代理服务

第一步:

注册阿里云,并购买服务器

阿里云

第二步:

去阿里云后台的容器镜像服,查看自己的专属镜像加速器地址

容器镜像服务

第三步:

安装或者升级docker,确保docker版本高于1.10.0

docker安装

第四步:

修改守护进程daemon的配置文件/etc/docker/daemon.json

vim命令指导

  1. vim /etc/docker/daemon.json

  2. 配置

{
"registry-mirrors": ["<a href="https://4wgtxa6q.mirror.aliyuncs.com">https://4wgtxa6q.mirror.aliyuncs.com</a>"]
}
  1. service docker restart //重启docker