阅读更多

0顶
0踩

开源软件

原创新闻 Docker操作

2022-07-13 13:17 by 见习记者 gaojingsong 评论(0) 有3006人浏览

[root@node1 ~]# cd /opt/

[root@node1 opt]# ls

apache-flume-1.9.0-bin.tar.gz   apache-zookeeper-3.6.3-bin.tar.gz               hadoop-3.0.0                      mirrors.cgi?action=download                nginx-1.19.1.tar.gz

apache-hive-2.1.1-bin.tar.gz    flink-1.7.0                                     iceberg-flink-runtime-0.10.0.jar  mirrors.cgi?action=download.1              rh

apache-pulsar-2.7.2             flink-1.7.0-bin-hadoop28-scala_2.12.tgz         jdk1.8.0_131                      mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz  scala-2.12.8.tgz

apache-pulsar-2.7.2-bin.tar.gz  flink-sql-connector-hive-2.3.6_2.11-1.11.0.jar  kafka_2.13-2.8.0.tgz              nacos                                      sqoop-1.4.7.tar.gz

[root@node1 opt]# systemctl status mysql

Unit mysql.service could not be found.

[root@node1 opt]# systemctl status docker

?docker.service - Docker Application Container Engine

   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)

   Active: inactive (dead)

     Docs: http://docs.docker.com

[root@node1 opt]# systemctl start docker

[root@node1 opt]# systemctl status docker

?docker.service - Docker Application Container Engine

   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)

   Active: active (running) since Thu 2021-06-03 14:53:07 CST; 3s ago

     Docs: http://docs.docker.com

 Main PID: 4396 (dockerd-current)

    Tasks: 17

   CGroup: /system.slice/docker.service

           忖4396 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-pat...

           忖4402 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/...

 

Jun 03 14:53:04 node1 dockerd-current[4396]: time="2021-06-03T14:53:04.446068657+08:00" level=info msg="libcontainerd: new containerd process, pid: 4402"

Jun 03 14:53:05 node1 dockerd-current[4396]: time="2021-06-03T14:53:05.734834925+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"

Jun 03 14:53:05 node1 dockerd-current[4396]: time="2021-06-03T14:53:05.736392737+08:00" level=info msg="Loading containers: start."

Jun 03 14:53:05 node1 dockerd-current[4396]: time="2021-06-03T14:53:05.865123160+08:00" level=info msg="Firewalld running: true"

Jun 03 14:53:06 node1 dockerd-current[4396]: time="2021-06-03T14:53:06.873226021+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon opt...d IP address"

Jun 03 14:53:07 node1 dockerd-current[4396]: time="2021-06-03T14:53:07.070178713+08:00" level=info msg="Loading containers: done."

Jun 03 14:53:07 node1 dockerd-current[4396]: time="2021-06-03T14:53:07.212263384+08:00" level=info msg="Daemon has completed initialization"

Jun 03 14:53:07 node1 dockerd-current[4396]: time="2021-06-03T14:53:07.212305820+08:00" level=info msg="Docker daemon" commit="cccb291/1.13.1" graphdriver=overlay2 version=1.13.1

Jun 03 14:53:07 node1 systemd[1]: Started Docker Application Container Engine.

Jun 03 14:53:07 node1 dockerd-current[4396]: time="2021-06-03T14:53:07.224890099+08:00" level=info msg="API listen on /var/run/docker.sock"

Hint: Some lines were ellipsized, use -l to show in full.

[root@node1 opt]# docker images

REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE

docker.io/kafkaesqueio/pulsar   2.6.2.1.0.1-beta2   b6054dcca615        6 days ago          1.95 GB

docker.io/wurstmeister/kafka    latest              4a83ed5f062f        12 days ago         438 MB

docker.io/redis                 latest              bc8d70f9ef6c        3 weeks ago         105 MB

docker.io/mysql                 latest              c0cdc95609f1        3 weeks ago         556 MB

docker.io/mysql                 <none>              a7a67c95e831        13 months ago       541 MB

docker.io/tomcat                latest              927899a31456        13 months ago       647 MB

docker.io/nginx                 latest              602e111c06b6        13 months ago       127 MB

docker.io/jaspeen/oracle-11g    latest              0c8711fe4f0f        5 years ago         281 MB

[root@node1 opt]# docker run --help

 

Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

 

Run a command in a new container

 

Options:

      --add-host list                         Add a custom host-to-IP mapping (host:ip) (default [])

  -a, --attach list                           Attach to STDIN, STDOUT or STDERR (default [])

      --blkio-weight uint16                   Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)

      --blkio-weight-device weighted-device   Block IO weight (relative device weight) (default [])

      --cap-add list                          Add Linux capabilities (default [])

      --cap-drop list                         Drop Linux capabilities (default [])

      --cgroup-parent string                  Optional parent cgroup for the container

      --cidfile string                        Write the container ID to the file

      --cpu-count int                         CPU count (Windows only)

      --cpu-percent int                       CPU percent (Windows only)

      --cpu-period int                        Limit CPU CFS (Completely Fair Scheduler) period

      --cpu-quota int                         Limit CPU CFS (Completely Fair Scheduler) quota

      --cpu-rt-period int                     Limit CPU real-time period in microseconds

      --cpu-rt-runtime int                    Limit CPU real-time runtime in microseconds

  -c, --cpu-shares int                        CPU shares (relative weight)

      --cpus decimal                          Number of CPUs (default 0.000)

      --cpuset-cpus string                    CPUs in which to allow execution (0-3, 0,1)

      --cpuset-mems string                    MEMs in which to allow execution (0-3, 0,1)

      --credentialspec string                 Credential spec for managed service account (Windows only)

  -d, --detach                                Run container in background and print container ID

      --detach-keys string                    Override the key sequence for detaching a container

      --device list                           Add a host device to the container (default [])

      --device-read-bps throttled-device      Limit read rate (bytes per second) from a device (default [])

      --device-read-iops throttled-device     Limit read rate (IO per second) from a device (default [])

      --device-write-bps throttled-device     Limit write rate (bytes per second) to a device (default [])

      --device-write-iops throttled-device    Limit write rate (IO per second) to a device (default [])

      --disable-content-trust                 Skip image verification (default true)

      --dns list                              Set custom DNS servers (default [])

      --dns-option list                       Set DNS options (default [])

      --dns-search list                       Set custom DNS search domains (default [])

      --entrypoint string                     Overwrite the default ENTRYPOINT of the image

  -e, --env list                              Set environment variables (default [])

      --env-file list                         Read in a file of environment variables (default [])

      --expose list                           Expose a port or a range of ports (default [])

      --group-add list                        Add additional groups to join (default [])

      --health-cmd string                     Command to run to check health

      --health-interval duration              Time between running the check (ns|us|ms|s|m|h) (default 0s)

      --health-retries int                    Consecutive failures needed to report unhealthy

      --health-timeout duration               Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s)

      --help                                  Print usage

  -h, --hostname string                       Container host name

      --init                                  Run an init inside the container that forwards signals and reaps processes

      --init-path string                      Path to the docker-init binary

  -i, --interactive                           Keep STDIN open even if not attached

      --io-maxbandwidth string                Maximum IO bandwidth limit for the system drive (Windows only)

      --io-maxiops uint                       Maximum IOps limit for the system drive (Windows only)

      --ip string                             Container IPv4 address (e.g. 172.30.100.104)

      --ip6 string                            Container IPv6 address (e.g. 2001:db8::33)

      --ipc string                            IPC namespace to use

      --isolation string                      Container isolation technology

      --kernel-memory string                  Kernel memory limit

  -l, --label list                            Set meta data on a container (default [])

      --label-file list                       Read in a line delimited file of labels (default [])

      --link list                             Add link to another container (default [])

      --link-local-ip list                    Container IPv4/IPv6 link-local addresses (default [])

      --log-driver string                     Logging driver for the container

      --log-opt list                          Log driver options (default [])

      --mac-address string                    Container MAC address (e.g. 92:d0:c6:0a:29:33)

  -m, --memory string                         Memory limit

      --memory-reservation string             Memory soft limit

      --memory-swap string                    Swap limit equal to memory plus swap: '-1' to enable unlimited swap

      --memory-swappiness int                 Tune container memory swappiness (0 to 100) (default -1)

      --name string                           Assign a name to the container

      --network string                        Connect a container to a network (default "default")

      --network-alias list                    Add network-scoped alias for the container (default [])

      --no-healthcheck                        Disable any container-specified HEALTHCHECK

      --oom-kill-disable                      Disable OOM Killer

      --oom-score-adj int                     Tune host's OOM preferences (-1000 to 1000)

      --pid string                            PID namespace to use

      --pids-limit int                        Tune container pids limit (set -1 for unlimited)

      --privileged                            Give extended privileges to this container

  -p, --publish list                          Publish a container's port(s) to the host (default [])

  -P, --publish-all                           Publish all exposed ports to random ports

      --read-only                             Mount the container's root filesystem as read only

      --restart string                        Restart policy to apply when a container exits (default "no")

      --rm                                    Automatically remove the container when it exits

      --runtime string                        Runtime to use for this container

      --security-opt list                     Security Options (default [])

      --shm-size string                       Size of /dev/shm, default value is 64MB

      --sig-proxy                             Proxy received signals to the process (default true)

      --stop-signal string                    Signal to stop a container, SIGTERM by default (default "SIGTERM")

      --stop-timeout int                      Timeout (in seconds) to stop a container

      --storage-opt list                      Storage driver options for the container (default [])

      --sysctl map                            Sysctl options (default map[])

      --tmpfs list                            Mount a tmpfs directory (default [])

  -t, --tty                                   Allocate a pseudo-TTY

      --ulimit ulimit                         Ulimit options (default [])

  -u, --user string                           Username or UID (format: <name|uid>[:<group|gid>])

      --userns string                         User namespace to use

      --uts string                            UTS namespace to use

  -v, --volume list                           Bind mount a volume (default [])

      --volume-driver string                  Optional volume driver for the container

      --volumes-from list                     Mount volumes from the specified container(s) (default [])

  -w, --workdir string                        Working directory inside the container

[root@node1 opt]# docker run --name mysqldb -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d  mysql

3abc248885e1760db8276a0f84982b6d82323196bfc1cd77e8e5d0547f468b75

[root@node1 opt]# docker images

REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE

docker.io/kafkaesqueio/pulsar   2.6.2.1.0.1-beta2   b6054dcca615        6 days ago          1.95 GB

docker.io/wurstmeister/kafka    latest              4a83ed5f062f        12 days ago         438 MB

docker.io/redis                 latest              bc8d70f9ef6c        3 weeks ago         105 MB

docker.io/mysql                 latest              c0cdc95609f1        3 weeks ago         556 MB

docker.io/mysql                 <none>              a7a67c95e831        13 months ago       541 MB

docker.io/tomcat                latest              927899a31456        13 months ago       647 MB

docker.io/nginx                 latest              602e111c06b6        13 months ago       127 MB

docker.io/jaspeen/oracle-11g    latest              0c8711fe4f0f        5 years ago         281 MB

[root@node1 opt]# docker ps  

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES

3abc248885e1        mysql               "docker-entrypoint..."   48 seconds ago      Up 46 seconds       0.0.0.0:3306->3306/tcp, 33060/tcp   mysqldb

[root@node1 opt]# mysql -uroot -p123456

bash: mysql: command not found...

[root@node1 opt]# systemctl status firewalld

?firewalld.service - firewalld - dynamic firewall daemon

   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)

   Active: active (running) since Thu 2021-06-03 14:03:52 CST; 56min ago

     Docs: man:firewalld(1)

 Main PID: 1175 (firewalld)

    Tasks: 2

   Memory: 820.0K

   CGroup: /system.slice/firewalld.service

           忖1175 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

 

Jun 03 14:53:06 node1 firewalld[1175]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE' failed: iptables: No chain/ta... by that name.

Jun 03 14:53:06 node1 firewalld[1175]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C DOCKER -i docker0 -j RETURN' failed: iptables: Bad rule (does a matching rule exist in that chain?).

Jun 03 14:53:06 node1 firewalld[1175]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -D FORWARD -i docker0 -o docker0 -j DROP' failed: iptables: Bad rule (does a matching rule exist in that chain?).

Jun 03 14:53:06 node1 firewalld[1175]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -i docker0 -o docker0 -j ACCEPT' failed: iptables: Bad rule (does a matchin... that chain?).

Jun 03 14:53:06 node1 firewalld[1175]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -i docker0 ! -o docker0 -j ACCEPT' failed: iptables: Bad rule (does a match... that chain?).

Jun 03 14:53:06 node1 firewalld[1175]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT' failed: ip... that chain?).

Jun 03 14:53:07 node1 firewalld[1175]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C FORWARD -o docker0 -j DOCKER' failed: iptables: No chain/target/match by that name.

Jun 03 14:58:11 node1 firewalld[1175]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C DOCKER -p tcp -d 0/0 --dport 3306 -j DNAT --to-destination 172.17.0.2:3306 ! -i docker... by that name.

Jun 03 14:58:11 node1 firewalld[1175]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t filter -C DOCKER ! -i docker0 -o docker0 -p tcp -d 172.17.0.2 --dport 3306 -j ACCEPT' failed:... that chain?).

Jun 03 14:58:11 node1 firewalld[1175]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -t nat -C POSTROUTING -p tcp -s 172.17.0.2 -d 172.17.0.2 --dport 3306 -j MASQUERADE' failed: ipt... by that name.

Hint: Some lines were ellipsized, use -l to show in full.

[root@node1 opt]# systemctl stop firewalld

[root@node1 opt]#  docker exec -it 3abc248885e1 /bin/bash

root@3abc248885e1:/# mysql -uroot -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 13

Server version: 8.0.25 MySQL Community Server - GPL

 

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

--  mysql 出现Client does not support authentication protocol requested by server解决方案

mysql> select host,user,plugin,authentication_string from mysql.user;

+-----------+------------------+-----------------------+------------------------------------------------------------------------+

| host      | user             | plugin                | authentication_string                                                  |

+-----------+------------------+-----------------------+------------------------------------------------------------------------+

z %     [RAa3Vdcn9HWRn6BKYd0fjqYGrDjbdqZlUyVHGktJEl018 | $A$005$7b^-3#b

| localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |

| localhost | mysql.session    | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |

| localhost | mysql.sys        | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |

| localhost | root             | caching_sha2_password | $A$005$%'oYB9S1gP)Sd

                                                                             9lj6GtGbI2Nlv8a59VW23Q2jDl5HQgBZuielhg/kY9dx5 |

+-----------+------------------+-----------------------+------------------------------------------------------------------------+

5 rows in set (0.13 sec)

 

mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

Query OK, 0 rows affected (0.11 sec)

 

mysql> 

 

0
0
评论 共 0 条 请登录后发表评论

发表评论

您还没有登录,请您登录后再发表评论

相关推荐

  • Docker 操作

    Docker 容器化技术

  • 从零开始的Docker Desktop使用,Docker快速上手 ( ̄︶ ̄) Docker介绍和基础使用

    Docker简介和安装 本博客主要解决在Windows环境下,快速上手使用Docker的问题,主要会介绍在Windows系统下Docker Desktop的安装,Docker 基础命令,比如说下载镜像、启动镜像...其他系统应该除了安装外其他操作都可以通用。

  • Docker操作Mysql镜像容器

    Docker操作Mysql镜像容器

  • docker的基本操作

    2、查看所有状态容器——docker ps -a ...二、docker 镜像操作 1、搜索镜像(公共仓库)——docker search 默认是在公共仓库找,如果有私有仓库,会在私有仓库找 2、下载镜像——docker pu

  • Docker的基本操作

    Docker的基本操作

  • python操作docker

    python操作docker

  • 5.Docker操作数据卷

    将容器与数据分离, 解耦合, 方便操作容器内的数据, 保证数据安全 2. 数据卷操作命令 #help 帮助 docker volume --help docker volume create ${数据卷名} ##创建数据卷 docker volume inspect${数据卷名} ##查看...

  • Docker常用操作指令

    一、Docker镜像操作

  • docker操作本地文件

    docker使用过程中,如果要操作本地文件,就需要在操作的目录中创建一个docker-compose.yml文件。 // docker-compose.yml version: '3' services: web: image: tesseractshadow/tesseract4re #build: . container...

  • 【使用记录1】青龙安装+docker操作

    docker容器操作 1、查看运行容器:docker ps 2、查看所有容器:docker ps -a 下面字符串d27bd3008ad9为容器ID,上图红框中 3、进入容器:docker exec -it d27bd3008ad9 /bin/bash 4、停止容器:docker stop ...

  • 给linux用户添加docker操作权限

    查看是否存在docker用户组cat /etc/group |grep docker 如果没有就添加一个groupadd docker 添加用户到docker分组addgroup xingxing docker 查看用户的分组groups xingxing 用户如果还是没有权限,可以尝试...

  • Docker操作镜像源

    Docker 下载镜像源 docker pull 'name':tag 如:docker pull mysql:8.0.19 不写tag默认least最新版 启动mysql8.0.19 docker run -p 3306:3306 --name mysqltest01 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:tag ...

  • aarch64服务器 离线安装docker操作手册

    一. 下载离线安装包 软件包网址: ...tar –zxvf docker-20.10.0.tgz cp docker/* /usr/bin/ /*不是注释! 四.

  • Docker常用命令总结

    docker常用命令解释及总结,简洁明了,清晰易懂

  • Docker最新超详细教程——基本操作

    Docker最新超详细教程——基本操作,Docker镜像、容器、数据卷。还有一个超好用的小工具finalshell

  • 【Docker学习】4. Docker操作容器

    文章目录 Docker操作容器 1. 启动容器 2. 终止容器 3. 启动已终止容器 4. 守护态运行(后台运行) 5. 容器日志 6. 进入容器 7. 删除容器 8. 清理所有处于终止状态的容器

  • Docker 容器内操作宿主机

    容器内部运行宿主机的docker命令 实现这种需求,其实非常简单,你只需要将docker宿主机的docker文件和docker.sock文件挂载到容器中即可,具体为: -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker...

  • docker 常用命令大全

    Docker 常用命令大全

  • centos8环境下安装docker操作实例

    查看linux系统内核版本:docker要求Centos系统的内核版本高于3.10,否则用yum update升级linux系统内核; [root@localhost ~]# clear [root@localhost ~]# uname -r 4.18.0-193.14.2.el8_2.x86_64 安装docker:...

  • Docker操作(二):如何修改tomcat镜像的端口

    1. 要求 修改tomcat镜像,要求把tomcat启动端口改成8889并启动容器 2. 思路 从tomcat的原始镜像启动一个tomcat容器 ...3. 操作步骤 3.1 用docker下载tomcat镜像,创建容器,启动/进入tomcat容器 .

Global site tag (gtag.js) - Google Analytics