Monthly Archives: July 2019

docker基础镜像alpine

alpine是面向安全应用的轻量级linux发行版本,拖下来看一下 [root@localhost ~]# docker pull alpine Using default tag: latest latest: Pulling from library/alpine 921b31ab772b: Pull complete Digest: sha256:ca1c944a4f8486a153024d9965aafbe24f5723c1d5c02f4964c045a16d19dc54 Status: Downloaded newer image for alpine:latest [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE alpine latest 4d90542f0623 2 weeks … Continue reading

Posted in Docker | Tagged | Leave a comment

docker查看镜像信息

这里我们用inspect来查看镜像的详细信息: [root@localhost ~]# docker inspect ubuntu:14.04 [ { “Id”: “sha256:2c5e00d77a67934d5e39493477f262b878f127b9c01b491f06d8f06f78819578”, “RepoTags”: [ “ubuntu:14.04” ], “RepoDigests”: [ “ubuntu@sha256:2f7c79927b346e436cc14c92bd4e5bd778c3bd7037f35bc639ac1589a7acfa90” ], “Parent”: “”, “Comment”: “”, “Created”: “2019-05-15T21:21:13.96007615Z”, “Container”: “0da171ebca7c967d1bc6e8bb0bc12658c5b2c8cc242c9c86f503dae0684a5cc7”, “ContainerConfig”: { “Hostname”: “0da171ebca7c”, “Domainname”: “”, “User”: “”, “AttachStdin”: false, “AttachStdout”: false, “AttachStderr”: false, … Continue reading

Posted in Docker | Tagged | Leave a comment

docker启动示范”hello world”

这个镜像很好说明了docker启动的完整过程,注意看对应的输出日志 [root@localhost ~]# docker run –rm hello-world Unable to find image ‘hello-world:latest’ locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be … Continue reading

Posted in Docker | Tagged | Leave a comment

docker diff/events命令

diff是用来比较容器和原镜像有什么区别,类似于git diff和status,这个直接用就行了,没太多好说的,比如刚才我们用docker cp复制了几份文件进入了ubuntu这个容器,看看有没有什么不同 [root@localhost ~]# docker diff ubuntu C /home A /home/rtest.txt A /home/rtest2.txt A /home/test.txt events是用来实时查看输出的,类似于tail -f ,所以你得重新打开个终端。比如,我们先start ubuntu_2,看看发生什么 [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES be9d5c6f2a25 ubuntu:14.04 “/bin/bash” 4 seconds ago Up … Continue reading

Posted in Docker | Tagged | Leave a comment

docker create/start 命令

docker 容器状态有一种是create,他的意思是创建了容器,但是还没启动,创建完成后,需要使用start来启动容器 我们可以试一下 先创建容器 [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7103a04f97d3 ubuntu:14.04 “/bin/bash” 3 hours ago Up 3 hours ubuntu [root@localhost ~]# docker images -a REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 14.04 … Continue reading

Posted in Docker | Tagged | Leave a comment

docker cp 命令使用方法

docker cp 的作用和linux 的cp是一样的,用来在宿主机和容器之间复制文件 [root@localhost ~]# docker cp –help Usage: docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|- docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH Copy files/folders between a container and the local filesystem Options: -a, –archive Archive mode (copy all uid/gid information) -L, –follow-link … Continue reading

Posted in Docker | Tagged | Leave a comment

docker attach命令使用

docker attach主要用来进入容器内部,之前创建了一个ubuntu的镜像,具体过程看之前的日志,现在进去瞅瞅 [root@localhost ~]# docker attach ubuntu root@7103a04f97d3:/# root@7103a04f97d3:/# ifconfig eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:02 inet addr:172.17.0.2 Bcast:172.17.255.255 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:22 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX … Continue reading

Posted in Docker | Tagged | Leave a comment

docker run命令使用

docker run :创建一个新的容器并运行一个命令 语法 docker run [OPTIONS] IMAGE [COMMAND] [ARG…] OPTIONS说明: -a stdin: 指定标准输入输出内容类型,可选 STDIN/STDOUT/STDERR 三项; -d: 后台运行容器,并返回容器ID; -i: 以交互模式运行容器,通常与 -t 同时使用; -P: 随机端口映射,容器内部端口随机映射到主机的高端口 -p: 指定端口映射,格式为:主机(宿主)端口:容器端口 -t: 为容器重新分配一个伪输入终端,通常与 -i 同时使用; –name=”nginx-lb”: 为容器指定一个名称; –dns 8.8.8.8: 指定容器使用的DNS服务器,默认和宿主一致; –dns-search example.com: 指定容器DNS搜索域名,默认和宿主一致; -h “mars”: … Continue reading

Posted in Docker | Tagged | Leave a comment

centos7:docker使用阿里云镜像加速器的方法

首先注册阿里云账号,这个不用说了 然后,进入控制台,找到容器镜像服务 (阿里控制台太乱了,我反正是找不到,网上搜了半天才找到连接:https://cr.console.aliyun.com/#/accelerator) 找到这个镜像加速器,怎么配置上面说得很清楚了,我就直接复制粘贴了: 针对Docker客户端版本大于 1.10.0 的用户 您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器 sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-‘EOF’ { “registry-mirrors”: [“https://此处隐藏,写你自己的.mirror.aliyuncs.com”] } EOF sudo systemctl daemon-reload sudo systemctl restart docker

Posted in Docker | Tagged | Leave a comment

Centos7上安装docker

Centos7上安装docker 改编自:https://www.cnblogs.com/yufeng218/p/8370670.html Docker从1.13版本之后采用时间线的方式作为版本号,分为社区版CE和企业版EE。 社区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外的收费服务,比如经过官方测试认证过的基础设施、容器、插件等。 社区版按照stable和edge两种方式发布,每个季度更新stable版本,如17.06,17.09;每个月份更新edge版本,如17.09,17.10。 一、安装docker 1、Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。 通过 uname -r 命令查看你当前的内核版本 $ uname -r [root@localhost ~]# uname -r 3.10.0-693.el7.x86_64 2、使用 root 权限登录 Centos。确保 yum 包更新到最新。 $ sudo yum update (代码不贴了) 3、卸载旧版本(如果安装过旧版本的话) $ … Continue reading

Posted in Docker | Tagged | Leave a comment