系统:ubuntu16.04
内核版本:4.4.167
硬件:rk3399
apt-get update
apt-get upgrade
apt-get install curl
有些版本内核(imx6q的4.1.15)可以直接下载官方检测内核配置脚本:
下载检测脚本sudo curl https://raw.githubusercontent.com/docker/docker/master/contrib/check-config.sh > check-config.sh
赋予执行权限chmod 777 check-config.sh
运行脚本./check-config.sh,会出现以下打印信息:
root@ParkW:/usr# ./check-config.sh
info: reading kernel config from /proc/config.gz ...
Generally Necessary:
- cgroup hierarchy: properly mounted [/sys/fs/cgroup]
- CONFIG_NAMESPACES: enabled
- CONFIG_NET_NS: enabled
- CONFIG_PID_NS: enabled
- CONFIG_IPC_NS: enabled
- CONFIG_UTS_NS: enabled
- CONFIG_CGROUPS: enabled
- CONFIG_CGROUP_CPUACCT: enabled
- CONFIG_CGROUP_DEVICE: enabled
- CONFIG_CGROUP_FREEZER: enabled
- CONFIG_CGROUP_SCHED: enabled
- CONFIG_CPUSETS: enabled
- CONFIG_MEMCG: enabled
- CONFIG_KEYS: enabled
- CONFIG_VETH: enabled
- CONFIG_BRIDGE: enabled
- CONFIG_BRIDGE_NETFILTER: enabled
- CONFIG_NF_NAT_IPV4: enabled
- CONFIG_IP: enabled
- CONFIG_IP_NF_TARGET_MASQUERADE: enabled
- CONFIG_NETFILTER_XT_MATCH_ADDRTYPE: enabled
- CONFIG_NETFILTER_XT_MATCH_CONNTRACK: enabled
- CONFIG_NETFILTER_XT_MATCH_IPVS: enabled
- CONFIG_IP_NF_NAT: enabled
- CONFIG_NF_NAT: enabled
- CONFIG_NF_NAT_NEEDED: enabled
- CONFIG_POSIX_MQUEUE: enabled
- CONFIG_DEVPTS_MULTIPLE_INSTANCES: enabled
Optional Features:
- CONFIG_USER_NS: missing
- CONFIG_SECCOMP: missing
- CONFIG_CGROUP_PIDS: missing
- CONFIG_MEMCG_SWAP: missing
- CONFIG_MEMCG_SWAP_ENABLED: missing
- CONFIG_MEMCG_KMEM: missing
- CONFIG_BLK_CGROUP: missing
- CONFIG_BLK_DEV_THROTTLING: missing
- CONFIG_IOSCHED_CFQ: enabled
- CONFIG_CFQ_GROUP_IOSCHED: missing
- CONFIG_CGROUP_PERF: missing
- CONFIG_CGROUP_HUGETLB: missing
- CONFIG_NET_CLS_CGROUP: enabled
- CONFIG_CGROUP_NET_PRIO: enabled
- CONFIG_CFS_BANDWIDTH: missing
- CONFIG_FAIR_GROUP_SCHED: enabled
- CONFIG_RT_GROUP_SCHED: missing
- CONFIG_IP_NF_TARGET_REDIRECT: enabled
- CONFIG_IP_VS: enabled
- CONFIG_IP_VS_NFCT: missing
- CONFIG_IP_VS_PROTO_TCP: missing
- CONFIG_IP_VS_PROTO_UDP: missing
- CONFIG_IP_VS_RR: missing
- CONFIG_EXT3_FS: enabled
- CONFIG_EXT3_FS_XATTR: enabled
- CONFIG_EXT3_FS_POSIX_ACL: enabled
- CONFIG_EXT3_FS_SECURITY: enabled
- CONFIG_EXT4_FS: enabled
- CONFIG_EXT4_FS_POSIX_ACL: enabled
- CONFIG_EXT4_FS_SECURITY: enabled
- Network Drivers:
- "overlay":
- CONFIG_VXLAN: missing
Optional (for encrypted networks):
- CONFIG_CRYPTO: enabled
- CONFIG_CRYPTO_AEAD: enabled
- CONFIG_CRYPTO_GCM: enabled
- CONFIG_CRYPTO_SEQIV: enabled
- CONFIG_CRYPTO_GHASH: enabled
- CONFIG_XFRM: enabled
- CONFIG_XFRM_USER: missing
- CONFIG_XFRM_ALGO: enabled
- CONFIG_INET_ESP: missing
- CONFIG_INET_XFRM_MODE_TRANSPORT: missing
- "ipvlan":
- CONFIG_IPVLAN: enabled
- "macvlan":
- CONFIG_MACVLAN: enabled
- CONFIG_DUMMY: missing
- "ftp,tftp client in container":
- CONFIG_NF_NAT_FTP: missing
- CONFIG_NF_CONNTRACK_FTP: missing
- CONFIG_NF_NAT_TFTP: missing
- CONFIG_NF_CONNTRACK_TFTP: missing
- Storage Drivers:
- "aufs":
- CONFIG_AUFS_FS: missing
- "btrfs":
- CONFIG_BTRFS_FS: missing
- CONFIG_BTRFS_FS_POSIX_ACL: missing
- "devicemapper":
- CONFIG_BLK_DEV_DM: missing
- CONFIG_DM_THIN_PROVISIONING: missing
- "overlay":
- CONFIG_OVERLAY_FS: enabled
- "zfs":
- /dev/zfs: missing
- zfs command: missing
- zpool command: missing
Limits:
- /proc/sys/kernel/keys/root_maxkeys: 1000000
需要将主要栏目(Generally Necessary:)内的非enabled的配置项目在内核源码中使用make ARCH=arm(arm64) menuconfig选中。
rk3399内核不能使用这个检测脚本,可以直接在内核源码中使用make ARCH=arm64 menuconfig,直接选中以下配置项即可:
- CONFIG_NAMESPACES: enabled
- CONFIG_NET_NS: enabled
- CONFIG_PID_NS: enabled
- CONFIG_IPC_NS: enabled
- CONFIG_UTS_NS: enabled
- CONFIG_CGROUPS: enabled
- CONFIG_CGROUP_CPUACCT: enabled
- CONFIG_CGROUP_DEVICE: enabled
- CONFIG_CGROUP_FREEZER: enabled
- CONFIG_CGROUP_SCHED: enabled
- CONFIG_CPUSETS: enabled
- CONFIG_MEMCG: enabled
- CONFIG_KEYS: enabled
- CONFIG_VETH: enabled
- CONFIG_BRIDGE: enabled
- CONFIG_BRIDGE_NETFILTER: enabled
- CONFIG_NF_NAT_IPV4: enabled
- CONFIG_IP: enabled
- CONFIG_IP_NF_TARGET_MASQUERADE: enabled
- CONFIG_NETFILTER_XT_MATCH_ADDRTYPE: enabled
- CONFIG_NETFILTER_XT_MATCH_CONNTRACK: enabled
- CONFIG_NETFILTER_XT_MATCH_IPVS: enabled
- CONFIG_IP_NF_NAT: enabled
- CONFIG_NF_NAT: enabled
- CONFIG_NF_NAT_NEEDED: enabled
- CONFIG_POSIX_MQUEUE: enabled
- CONFIG_DEVPTS_MULTIPLE_INSTANCES: enabled
使用命令获得安装脚本, docker不建议使用apt-get来安装, 据网上的大神说ubuntu官方源安装的docker不能使用:
curl -fssl https://get.docker.com -o get-docker.sh
赋予执行权限:chmod 777 get-docker.sh
执行安装脚本进行安装:./get-docker.sh
1)启动docker服务
service docker start
2)启动某个image(镜像)的container(容器)
docker的镜像称为image,容器为container
对于Docker来说,image是静态的,类似于操作系统快照,而container则是动态的,是image的运行实例。
比如,有一个image名称为ubuntu,那么比如现在我们启动这个image的container并且进入到这个container的bash命令行中:
docker run -t -i ubuntu /bin/bash
docker run:启动container
ubuntu:你想要启动的image
-t:进入终端
-i:获得一个交互式的连接,通过获取container的输入
/bin/bash:在container中启动一个bash shell
这样就进入container的内部了:
root@4c69aba0c516:/#
如果要正常退出不关闭容器,请按Ctrl+P+Q进行退出容器,即容器后台运行。
如果要正常退出并关闭,请输入exit 进行退出容器,即容器关闭退出。
如果有运行中的container,可以在container所在的外部操作系统中运行,这个命令可以查看当前正在运行的容器:docker ps
docker ps
root@EmbedSky-Board:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c69aba0c516 ubuntu "/bin/bash" 38 seconds ago Up 35 seconds jolly_chaplygin
如果想看到所有的container,包括运行中的,以及未运行的或者说是沉睡镜像,和运行过已经关闭的,则运行:docker ps -a
docker ps -a
root@EmbedSky-Board:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c69aba0c516 ubuntu "/bin/bash" About a minute ago Up About a minute jolly_chaplygin
bda09e02db27 ubuntu "/bin/bash" 3 minutes ago Exited (0) About a minute ago wizardly_taussig
b584ccc188fd ubuntu "/bin/bash" 7 minutes ago Exited (0) About a minute ago stupefied_chaum
ab9ace972eb0 ubuntu "/bin/bash" About an hour ago Exited (0) 26 minutes ago sad_curie
使用docker restart [NAMES]命令重启容器,用于用exit退出后已关闭的容器重启,最后一个参数是docker ps -a查看的最后一项NAMES,如:
root@ab9ace972eb0:/# exit
exit
root@EmbedSky-Board:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@EmbedSky-Board:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ab9ace972eb0 ubuntu "/bin/bash" About an hour ago Exited (0) About a minute ago sad_curie
root@EmbedSky-Board:~# docker restart sad_curie
sad_curie
root@EmbedSky-Board:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ab9ace972eb0 ubuntu "/bin/bash" About an hour ago Up 19 seconds sad_curie
使用docker attach [NAMES] 命令进入容器,用于后台运行没有被关闭的容器,即使用命令docker ps可以看到的:
root@4c69aba0c516:/# 使用ctrl+Q+P
root@EmbedSky-Board:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c69aba0c516 ubuntu "/bin/bash" 11 minutes ago Up 11 minutes jolly_chaplygin
root@EmbedSky-Board:~# docker attach jolly_chaplygin
root@4c69aba0c516:/#