普拉多VX

人生一路,不问来时,不知归期

0%

docker for Mac安装

docker 下载

前往Docker官网下载Docker dmg包

官网:https://www.docker.com/get-started 下载docker desktop

docker 安装

下载dmg方式会出现如下错误

1
mac for docker The operation couldn’t be completed. (Docker.VmnetdError error 1.)

以上方法无法安装,采用阿里的docker可以安装成功。

安装 阿里docker

官网 http://mirrors.aliyun.com/docker-toolbox/mac/docker-for-mac/stable/

docker 命令

1
2
3
4
5
6
7
8
9

docker ps //查看运行状态
docker start //启动一个容器
docker verison //查看docker版本
docker rm //删除容器
docker rename //重命名一个容器
docker logs //查看容器日志
docker attach //进入容器
....

修改默认仓库

点击logo——> preferences——> docker engine 修改成如下配置

1
2
3
4
5
6
7
8
{
"experimental": false,
"debug": true,
"registry-mirrors":[
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}

docker info

可以看到mirrors修改成功

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
luodi@roddydeMacBook-Pro:~$ docker info
Client:
Debug Mode: false

Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.8
Storage Driver: overlay2
Backing Filesystem: <unknown>
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.19.76-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.945GiB
Name: docker-desktop
ID: 2W5N:QPGQ:H5KA:GNGN:LWWY:IQFC:BD5N:D3XZ:GNDK:N2IH:J7AI:5JEH
Docker Root Dir: /var/lib/docker
Debug Mode: true
File Descriptors: 51
Goroutines: 100
System Time: 2020-07-01T08:46:32.000970455Z
EventsListeners: 3
HTTP Proxy: gateway.docker.internal:3128
HTTPS Proxy: gateway.docker.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
http://hub-mirror.c.163.com/
https://docker.mirrors.ustc.edu.cn/
Live Restore Enabled: false
Product License: Community Engine

docker 运行mysql

对外暴露端口3308 密码 root12334

1
luodi@roddydeMacBook-Pro:~$ docker run --name mysqlgo -p 3308:3306 -e MYSQL_ROOT_PASSWORD=root1234 -d mysql:8.0.19

查看运行状态

1
2
3
4
luodi@roddydeMacBook-Pro:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
610d8c36f67c mysql:8.0.19 "docker-entrypoint.s…" 16 seconds ago Up 15 seconds 33060/tcp, 0.0.0.0:3308->3306/tcp mysqlgo
luodi@roddydeMacBook-Pro:~$

启动一个连接客户端

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$ docker run -it --network host --rm mysql mysql -h127.0.0.1 -P3308 --default-character-set=utf8mb4 -uroot -p
Unable to find image 'mysql:latest' locally
latest: Pulling from library/mysql
8559a31e96f4: Pull complete
d51ce1c2e575: Pull complete
c2344adc4858: Pull complete
fcf3ceff18fc: Pull complete
16da0c38dc5b: Pull complete
b905d1797e97: Pull complete
4b50d1c6b05c: Pull complete
c75914a65ca2: Pull complete
1ae8042bdd09: Pull complete
453ac13c00a3: Pull complete
9e680cd72f08: Pull complete
a6b5dc864b6c: Pull complete
Digest: sha256:8b7b328a7ff6de46ef96bcf83af048cb00a1c86282bfca0cb119c84568b4caf6
Status: Downloaded newer image for mysql:latest
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.19 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.07 sec)

mysql>
mysql>
mysql> create database gotest;
Query OK, 1 row affected (0.02 sec)

mysql>

brew安装参考文档

如果使用brew安装参考如下