0. docker和nvidia-docker

一文快速入门docker和nvidia-docker

1. docker安装fastdfs

搜索fastdfs
docker search fastdfs
拉取镜像
docker pull season/fastdfs:1.2
创建本地目录,并启动容器

创建tracker目录,该目录用于和tracker进行目录挂载

sudo mkdir /opt/fastdfs/data/tracker

创建并启动tracker容器

sudo docker run -id --name tracker --restart=always --net host -v /etc/localtime:/etc/localtime -v /opt/fastdfs/data/tracker:/fastdfs/tracker/data season/fastdfs:1.2 tracker

创建storage目录,该目录存储上传的文件

sudo mkdir /opt/fastdfs/data/storage

创建并启动storage的容器

sudo docker run -id --name storage --restart=always --net host -v /etc/localtime:/etc/localtime -v /opt/fastdfs/data/storage:/fastdfs/store_path -e TRACKER_SERVER="192.168.20.99:22122" season/fastdfs:1.2 storage
修改配置文件

将tracker容器中的客户端配置文件client.conf复制到宿主机,进行修改client.conf配置文件,

docker cp tracker:/etc/fdfs/client.conf /opt/fastdfs/data/tracker/

#将 client.conf文件中 tracker_server的ip改为你linux服务器的ip

tracker_server=192.168.20.99:22122

再将拷贝到宿主机上的client.conf文件 复制回tracker容器

docker cp /opt/fastdfs/data/tracker/client.conf tracker:/etc/fdfs/
进入tracker容器,执行命令
docker exec -it tracker bash

创建文件,执行命令

echo "zhangshoufu.com" >index.html

将文件上传到服务器,执行命令

fdfs_upload_file /etc/fdfs/client.conf index.html
配置nginx

创建nginx配置文件的文件夹

sudo mkdir /opt/fastdfs/data/nginx

将storage容器中的nginx配置文件拷贝到你创建的nginx文件夹下

docker cp storage:/etc/nginx/conf/nginx.conf /opt/fastdfs/data/nginx/

创建nginx的容器

sudo docker run -id --name fastdfs_nginx --restart=always -v /opt/fastdfs/data/storage:/fastdfs/store_path -v /opt/fastdfs/data/nginx/nginx.conf:/etc/nginx/conf/nginx.conf -p 8888:80 -e TRACKER_SERVER=192.168.20.99:22122 season/fastdfs:1.2 nginx

修改nginx的配置文件,部分内容修改如下

location /group1/M00 {
            root   /fastdfs/store_path/data;
            ngx_fastdfs_module;
        }

重启fastdfs_nginx容器

docker restart fastdfs_nginx
python上传图片到fastdfs,并网页展示
from fdfs_client.client import Fdfs_client, get_tracker_conf

# client.conf 为 tracker 容器中的 client.conf
client_conf = get_tracker_conf(r'client.conf')
client = Fdfs_client(client_conf)
ret = client.upload_by_filename('1.jpg')
result = str(ret['Remote file_id'], 'utf-8')
img_url = fastdfs_base_url + result
return img_url

参考:手把手教你docker搭建fastDFS文件上传下载服务器


2. docker 安装 tomcat

参考:Docker 安装 Tomcat

  1. 拉取镜像
docker pull tomcat
  1. 启动tomcat
docker run --name tomcat --restart=always -p 8080:8080 -v /opt/soft/services/tomcat8.5/webapps:/usr/local/tomcat/webapps -d tomcat

3. Docker 安装 ActiveMQ

Docker 安装 ActiveMQ


4. docker container 里配置 jupyter lab

下载jupyter notebook

pip install jupyter notebook
  1. 配置远程访问jupyter
  • 生成密码
ipython
from notebook.auth import passwd
passwd()

输完之后,设定一个密码,会生成一个sha1的秘钥会有如下的结果:

quit()
  • 生成jupyter notebook的配置文件
jupyter notebook --generate-config

这时候会生成配置文件,在 ~/.jupyter/jupyter_notebook_config.py

  • 修改配置文件
vim ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip='*'
# 目录
c.NotebookApp.notebook_dir = '/workspace'
# 上面生成的秘钥
c.NotebookApp.password = u'argon2:$argon2id$v=19$m=10240,t=10,p=8$B5b+4guljAwGmfDWR/Inmg$iWlSYIEQ+9ZxnibbUSsFJA'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8899
  • 打开jupyter notebook
jupyter notebook --allow-root &                                      

5. docker 安装 kafka

  1. 安装 docker
# 获取最新版本的 Docker 安装包 并安装
apt-get update
apt-get install -y docker.io
# 启动docker 后台服务
service docker start
  1. docker 安装 kafka
#1:kafka需要zookeeper管理,所以需要先安装zookeeper。 下载docker pull wurstmeister/zookeeper:latest版本
docker pull wurstmeister/zookeeper
# 2:启动镜像生成容器
docker run -d --name zookeeper -p 2181:2181 -v /etc/localtime:/etc/localtime wurstmeister/zookeeper
# 3:下载kafka镜像
docker pull wurstmeister/kafka
# 4:启动kafka镜像生成容器 
# -e KAFKA_BROKER_ID=0  在kafka集群中,每个kafka都有一个BROKER_ID来区分自己
# -e KAFKA_ZOOKEEPER_CONNECT=192.168.155.56:2181/kafka 配置zookeeper管理kafka的路径# 192.168.155.56:2181/kafka
# -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.155.56:9092  把kafka的地址端口注册给zookeeper
# -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 配置kafka的监听端口
# -v /etc/localtime:/etc/localtime 容器时间同步虚拟机的时间

# old已失效
docker run -d --name kafka -p 9092:9092 -e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT=192.168.155.56:2181/kafka -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.155.56:9092 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -v /etc/localtime:/etc/localtime wurstmeister/kafka

#new 有效
docker run -d --name kafka_haidian_iphoneconnect -p 9092:9092 --link zookeeper:zookeeper --env KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 --env KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 --env KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 --env KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 wurstmeister/kafka
# 5:验证kafka是否可以使用
docker exec -it kafka /bin/sh
# 进入路径:/opt/kafka_2.11-2.0.0/bin下
# 运行kafka生产者发送消息
./kafka-console-producer.sh --broker-list localhost:9092 --topic sun
# 发送消息
{"datas":[{"channel":"","metric":"temperature","producer":"ijinus","sn":"IJA0101-00002245","time":"1543207156000","value":"80"}],"ver":"1.0"}

# 6:运行kafka消费者接收消息
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic sun --from-beginning


docker run -d --name kafka -p kafka公网映射端口:9092 -e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT=公网ip:zookeeper公网映射端口/kafka -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://公网ip:kafka公网映射端口 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -v /etc/localtime:/etc/localtime wurstmeister/kafka

下载离线包安装
1: 下载 链接:https://pan.baidu.com/s/1ggdvpGv 密码:rjtt
2: 解压后修改 server.properties 文件
broker.id=0
port=9092
host.name=192.168.25.175
advertised.host.name=192.168.25.175
log.dirs=自己创建一个log目录
num.partitions=2
zookeeper.connect=192.168.25.175
3: 启动 进入到 bin目录下
./kafka-server-start.sh …/config/server.properties &

4: 下载kafka-manager-1.0-SNAPSHOT.zip 链接:https://pan.baidu.com/s/1eTIEMK6 密码:0qf7

5: 解压后更改 application.conf
kafka-manager.zkhosts=“192.168.25.175”

6: 进入到 bin 目录下 启动
nohup kafka-manager -Dconfig.file=/usr/local/my-servers/kafka/kafka-manager-1.0/conf/application.conf >/dev/null 2>&1 &


6. ubutun安装mysql并开启远程访问

  1. docker 安装 mysql
# 搜索mysql
docker search mysql
# 拉取 mysal
docker pull mysql:8.0.32
# 运行mysql
docker run -itd --name mysql --restart=always -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql
  1. navicat连接Docker -Mysql报错:caching sha_2_password cannot be load

进入docker

mysql -u root -p
use mysql;
select user, host,plugin,authentication_string from user;
alter user 'root'@'%' identified with mysql_native_password by 'root';

  1. 卸载mysql
  • 首先在终端中查看MySQL的依赖项:dpkg --list|grep mysql
  • 卸载: sudo apt-get remove mysql-common
  • 卸载:sudo apt-get autoremove --purge mysql-server-5.7
  • 清除残留数据:dpkg -l|grep ^rc|awk '{print$2}'|sudo xargs dpkg -P
  • 再次查看MySQL的剩余依赖项:dpkg --list|grep mysql
  • 继续删除剩余依赖项,如:sudo apt-get autoremove --purge mysql-apt-config
  • 至此已经没有了MySQL的依赖项,彻底删除,Good Luck

  1. 安装mysql
sudo apt-get update
sudo apt-get install mysql-server
  1. 设置mysql密码
mysql -uroot -p
show databases;
use mysql;
update user set authentication_string=PASSWORD("admin888.") where user='root';
update user set plugin="mysql_native_password";
flush privileges;
quit;

如果不能远程访问,请按照下面操作
3. 开启远程访问

mysql -ur oot -p
mysql> use mysql;
mysql> update user set host = '%' where user = 'root';
mysql> select host, user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | root             |
| localhost | debian-sys-maint |
| localhost | mysql.session    |
| localhost | mysql.sys        |
+-----------+------------------+

#ok 退出MySQL 重启服务
mysql> quit;
$ service mysql restart
#发现客户端远程还是连接不上 继续修改mysql.cnf配置文件
#需要root权限,配置文件是只读的
$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
#往下翻,注释掉这一行,保存退出
# bind-address          = 127.0.0.1
#重启服务
$ service mysql restart;
#ok 可以了

或者

#允许所有用户远程访问 修改用户名和密码为你自己的
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
#允许单个ip 修改用户名和密码为你自己的
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
#最后
mysql> FLUSH PRIVILEGES;
  • 6.1 命令行执行sql脚本
# 从主机复制文件到容器
sudo docker cp host_path containerID:container_path
# 从容器复制文件到主机
sudo docker cp containerID:container_path host_path

# 进入容器连接mysql,选择数据库,执行sql文件
mysql -u root -p
use mysql;
source /opt/a.sql

7. Docker 安装 Redis

  1. 查看可用的 Redis 版本 docker search redis
  2. 取最新版的 Redis 镜像
docker pull redis:latest
  1. 运行容器
docker run -itd --name redis  --restart=always -p 6379:6379 redis
  1. 设置密码
docker run -d --name redis --restart=always -p 6378:6379 镜像地址 --requirepass 123456 
  1. 测试
docker exec -it redis-test /bin/bash
  • redis-cli

8. ubuntu 安装 redis-desktop-manager

sudo snap install redis-desktop-manager

9. Docker 安装 Nextcloud

sudo docker pull nextcloud
sudo docker run -d --name nextcloud --restart=always -p 80:80 -v /opt/soft/geekplusa/nextcloud:/var/www/html nextcloud

10. docker 安装 rabbitmq

参考:用docker部署RabbitMQ环境

sudo docker pull rabbitmq:management
sudo docker run -dit --name rabbitmq -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin -p 15672:15672 -p 5672:5672 rabbitmq:management

11. docker 安装 postgresql

-d --name redis --restart=always -p 6378:6379 镜像地址

sudo docker pull docker.io/postgres
sudo docker run -d --name postgres --restart=always -v /opt/servers/postgresql/data:/var/lib/postgresql/data --privileged=true -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres

12. docker安装api网关-kong

以Docker方式安装和配置Kong网关和Konga控制台

1. 创建容器网络

docker network create kong-net

2. 安装并启动PostgreSQL数据库
# 拉取镜像
docker pull docker.io/postgres:9.6
# 启动PostgreSQL数据库
docker run -d --name kong-database \
               --network=kong-net \
               -p 5432:5432 \
               -v /opt/services/kong/db/pgdata:/var/lib/postgresql/data \
               -e "POSTGRES_USER=kong" \
               -e "POSTGRES_DB=kong" \
               -e "POSTGRES_PASSWORD=kong" \
               postgres:9.6

# 初始化数据
docker run --rm \
     --network=kong-net \
     -e "KONG_DATABASE=postgres" \
     -e "KONG_PG_HOST=kong-database" \
     -e "KONG_PG_USER=kong" \
     -e "KONG_PG_PASSWORD=kong" \
     kong:latest kong migrations bootstrap
3. 对Kong Admin API作安全防护,安装并启动Kong

创建配置文件/opt/services/kong/config/kong.yml,内容如下

_format_version: "1.1"

services:
- name: admin-api
  url: http://192.168.101.203:8001
  routes:
    - paths:
      - /admin-api
  plugins:
  - name: key-auth

consumers:
- username: admin
  keyauth_credentials:
  - key: secret

  1. 导入Kong配置:
docker run --rm \
    --network=kong-net \
    -e "KONG_DATABASE=postgres" \
    -e "KONG_PG_HOST=kong-database" \
    -e "KONG_PG_USER=kong" \
    -e "KONG_PG_PASSWORD=kong" \
    -v /opt/services/kong/config:/home/kong \
    kong:latest kong config db_import /home/kong/kong.yml
  1. 拉取kong镜像
docker pull docker.io/kong
  1. 启动kong
docker run -d --name kong \
     --network=kong-net \
     -e "KONG_DATABASE=postgres" \
     -e "KONG_PG_HOST=kong-database" \
     -e "KONG_PG_USER=kong" \
     -e "KONG_PG_PASSWORD=kong" \
     -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
     -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
     -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
     -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
     -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
     -p 8000:8000 \
     -p 8443:8443 \
     -p 192.168.101.203:8001:8001 \
     -p 192.168.101.203:8444:8444 \
     kong:latest
  1. 测试kong可用
http://192.168.101.203:8000/admin-api?apikey=secret
4. 安装Konga
  1. 启动konga PostgresSQL数据库。
docker run -d --name konga-database \
               --network=kong-net \
               -p 5433:5432 \
               -v /opt/services/kong/konga/postgres-data:/var/lib/postgresql/data \
               -e "POSTGRES_USER=konga" \
               -e "POSTGRES_DB=konga" \
               -e "POSTGRES_PASSWORD=konga" \
               postgres:9.6
  1. 初始化数据
    创建/opt/services/kong/konga/postgres-data文件夹,初始化数据库
# 拉取konga镜像
docker pull pantsel/konga
# 初始化数据
docker run --rm \
             --network=kong-net \
             pantsel/konga:latest \
             -c prepare \
             -a "postgres" \
             -u "postgres://konga:konga@konga-database:5432/konga"
  1. 启动Konga
docker run -d --name konga \
             --network kong-net \
             -e "TOKEN_SECRET=secret123" \
             -e "DB_ADAPTER=postgres" \
             -e "DB_URI=postgres://konga:konga@konga-database:5432/konga" \
             -e "NODE_ENV=development" \
             -p 1337:1337 \
             pantsel/konga
5. 在Konga上配置
  1. 登录konga后台 http://192.168.101.203:1337
  2. 注册admin用户
  3. 配置Kong连接
在Konga上,打开Connections,选择新建一个Kong连接。
选择连接类型为Kong Auth,输入连接名称、Loopback API URL和API Key。

13. docker添加端口映射

  • 1.停掉docker
  systemcel stop docker
    1. 在 /var/lib/docker/containers/[容器ID]/下找到hostconfig.json、config.v2.json
      hostconfig.json
"PortBindings": {
    "888/tcp": [
      {
        "HostIp": "",
        "HostPort": "888"
      }
    ],
    "21/tcp": [
      {
        "HostIp": "",
        "HostPort": "21"
      }
    ]
}

config.v2.json

"ExposedPorts": {
  "888/tcp": {},
  "21/tcp": {}
}


"Ports": {
    "888/tcp": [
        {
          "HostIp": "0.0.0.0",
          "HostPort": "888"
        }
    ],
    "21/tcp": [
        {
          "HostIp": "0.0.0.0",
          "HostPort": "21"
        }
    ]
}

    1. 启动docker
systemctl start docker

14. docker启动使用所有显卡

docker run -itd --name wxd_baai --restart=always -p 16000:6000 -p 16001:6001 -p 16002:6002 -v /opt/wxd/dockerfile/baai:/opt/models/baai 56fe0d666312

15. docker 启动 mogublog

sudo docker run -itd  -h mogu_blog_2 --name mogu_blog_2 -v /home/geekplusa/ai/datasets/docker/mogublog:/etc -p 11122:22 -p 15672:15672 -p 8600:8600 -p 9527:9527 -p 9528:9528 -p 16379:6379 -p 23306:3306 -p 10080:80 -p 8080:8080 -p 8601:8601 -p 8602:8602 -p 8603:8603 -p 8604:8604 -p 8605:8605 -p 8606:8606 -p 8607:8607 -p 5601:5601 -p 9411:9411 -p 465:465 -p 8848:8848 -p 8070:8070 moxi/mogu_blog_nacos

16. docker安装nacos

  • 1. 拉取镜像
docker pull nacos/nacos-server 
  • 2. 查询本地mysql ip地址
docker inspect mysql | grep IPAddress
  • 3. 启动 已废弃
docker run -d \
-e MODE=standalone \
-e SPRING_DATASOURCE_PLATFORM=mysql \
-e MYSQL_SERVICE_HOST=172.17.0.3 \
-e MYSQL_SERVICE_PORT=3306 \
-e MYSQL_SERVICE_USER=root \
-e MYSQL_SERVICE_PASSWORD=root \
-e MYSQL_SERVICE_DB_NAME=nacos_config \
-p 8848:8848 \
--restart=always \
--name nacos \
nacos/nacos-server
  • 3. 启动
sudo docker run \
--name nacos -d \
-p 8848:8848 \
--privileged=true \
--restart=always \
-e JVM_XMS=256m \
-e JVM_XMX=256m \
-e MODE=standalone \
-e PREFER_HOST_MODE=hostname \
-v /home/geekplusa/ai/datasets/docker/nacos/logs:/home/nacos/logs \
-v /home/geekplusa/ai/datasets/docker/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties \
-v /home/geekplusa/ai/datasets/docker/nacos/data:/home/nacos/data \
nacos/nacos-server

custom.properties

server.contextPath=/nacos
server.servlet.contextPath=/nacos
server.port=8848
​
spring.datasource.platform=mysql
​
db.num=1
db.url.0=jdbc:mysql://172.17.0.5:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false
db.user=root
db.password=root
​
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
​
management.metrics.export.elastic.enabled=false
​
management.metrics.export.influx.enabled=false
​
​
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i
​
​
nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health/**,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**,/v1/console/server/**
nacos.naming.distro.taskDispatchThreadCount=1
nacos.naming.distro.taskDispatchPeriod=200
nacos.naming.distro.batchSyncKeyCount=1000
nacos.naming.distro.initDataRatio=0.9
nacos.naming.distro.syncRetryDelay=5000
nacos.naming.data.warmup=true
nacos.naming.expireInstance=true

17. 192.168.101.28服务器启动yolov5容器

docker run -itd --name wxd_pytorch_yolov5 --shm-size 8G -p 30010:6000 -p 30011:5000 -v /kolla/wxd/projects/yolo:/opt/projects/yolo 1caa84597263
sudo apt update
sudo apt install libglib2.0-dev
sudo apt install libgl1-mesa-glx

18. 192.168.101.88服务器启动yolov5容器

docker run -itd --name wxd_pytorch_yolov5 --shm-size 8G -p 30010:6000 -p 30011:5000 -v /opt/wxd/dockerfile/yolo:/opt/projects/yolo 869be8b6396a
sudo apt update
sudo apt install libglib2.0-dev
sudo apt install libgl1-mesa-glx

19. 192.168.101.88服务器启动paddledetection容器

docker run -itd --name wxd_paddle_paddledet --shm-size 8G -p 30050:6000 -p 30051:5000 -v /opt/wxd/dockerfile/paddledetection:/opt/projects/paddledetection fb5bd3a2ad69
sudo apt update
sudo apt install libglib2.0-dev
sudo apt install libgl1-mesa-glx

20. 192.168.101.88服务器启动aigc容器

docker run -itd --name wxd_pytorch_aigc --shm-size 8G -p 30020:6000 -p 30021:5000 -v /opt/wxd/dockerfile:/opt/projects 869be8b6396a
sudo apt update
sudo apt install libglib2.0-dev
sudo apt install libgl1-mesa-glx

21. docker install 流媒体服务器

docker pull bluenviron/mediamtx

docker run -itd --name media_server --restart=always
-e MTX_PROTOCOLS=tcp
-e MTX_WEBRTCADDITIONALHOSTS=192.168.1.147
-p 8554:8554
-p 1935:1935
-p 8888:8888
-p 8889:8889
-p 8890:8890/udp
-p 8189:8189/udp
bluenviron/mediamtx

22. docker安装wvp

docker pull 648540858/wvp_pro
docker run  --env WVP_IP="10.0.2.249" -itd --name wvp -p 18080:18080 -p 30000-30500:30000-30500/udp -p 30000-30500:30000-30500/tcp -p 10080:80 -p 5060:5060 -p 5060:5060/udp 648540858/wvp_pro

23. docker安装rabbitmq

docker pull rabbitmq:management
docker run -id --name=rabbitmq -v rabbitmq-home:/var/lib/rabbitmq -p 15672:15672 -p 5672:5672 -e RABBITMQ_DEFAULT_USER=lidar -e RABBITMQ_DEFAULT_PASS=lidar-pass rabbitmq:management

23. docker安装宝塔面板

  • new
docker run -itd --name baota -p 8888:8888 -p 10022:22 -p 10443:443 -p 80:80 -p 888:888 -p 3306:3306 -v ~/baota/wwwroot:/www/wwwroot -v ~/baota/mysql_data:/www/server/data -v ~/baota/vhost:/www/server/panel/vhost btpanel/baota:7.9.4-lnmp
  • error
docker run -tid --name baota -p 8080:80 -p 493:443 -p 8888:8888 -p 888:888 -p 3306:3306 --privileged=true -v /data/baota/:/www/wwwroot pch18/baota

24. docker mysql导入导出

  • 导出
docker exec -it mysql mysqldump -uusername -ppassword databases > /opt/sql.sql
  • 导入
# 进入容器连接mysql,选择数据库,执行sql文件
mysql -u root -p
use mysql;
CREATE DATABASE `databases`
use databases;
source /opt/a.sql

25. 本地docker镜像上传阿里云镜像

docker login --username=username registry.cn-hangzhou.aliyuncs.com

docker tag imageid registry.cn-hangzhou.aliyuncs.com/shkj123/visual_env_base:v1

docker push registry.cn-hangzhou.aliyuncs.com/shkj123/visual_env_base:v1

26. docker安装ftp

参考:1-Docker - 搭建FTP服务器

100. docker错误解决


    1. docker出错 OCI runtime create failed exec: “nvidia-container-runtime”:
      问题描述

docker: Error response from daemon: OCI runtime create failed: unable
to retrieve OCI runtime error (open
/run/containerd/io.containerd.runtime.v2.task/moby/ba8972872229c25598420b9597ba8de8de2033a788b7d2ec85ed97727d13baa7/log.json:
no such file or directory): exec: “nvidia-container-runtime”:
executable file not found in $PATH: : unknown.

解决
安装nvidia-docker

curl https://get.docker.com | sh   && sudo systemctl --now enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo -E apt-get update
sudo -E apt-get install -y nvidia-docker2
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐