独书先生 Menu

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学习欢迎关注我的更新。

参考

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