zoukankan      html  css  js  c++  java
  • docker基础概念

    如果现在docker内运行一个ubuntu系统内的bash输出一个“hello world”那么可以这样做

    [root@VM_0_9_centos ~]# docker run ubuntu:15.10 /bin/echo "hello world"
    Unable to find image 'ubuntu:15.10' locally
    Trying to pull repository docker.io/library/ubuntu ...
    15.10: Pulling from docker.io/library/ubuntu
    7dcf5a444392: Pull complete
    759aa75f3cee: Pull complete
    3fa871dc8a2b: Pull complete
    224c42ae46e7: Pull complete
    Digest: sha256:02521a2d079595241c6793b2044f02eecf294034f31d6e235ac4b2b54ffc41f3
    Status: Downloaded newer image for docker.io/ubuntu:15.10
    hello world

    这样输出就没了。如果想在容器内交互运行的话,可以加-i -t参数

    [root@VM_0_9_centos ~]# docker run -i -t  ubuntu:15.10 /bin/bash
    root@13a0527cc2f3:/# hello
    bash: hello: command not found
    root@13a0527cc2f3:/# ll
    total 72
    drwxr-xr-x   1 root root 4096 Jan  7 08:09 ./
    drwxr-xr-x   1 root root 4096 Jan  7 08:09 ../
    -rwxr-xr-x   1 root root    0 Jan  7 08:09 .dockerenv*
    drwxr-xr-x   2 root root 4096 Jul  6  2016 bin/
    drwxr-xr-x   2 root root 4096 Oct 19  2015 boot/
    drwxr-xr-x   5 root root  360 Jan  7 08:09 dev/
    drwxr-xr-x   1 root root 4096 Jan  7 08:09 etc/
    drwxr-xr-x   2 root root 4096 Oct 19  2015 home/
    drwxr-xr-x   8 root root 4096 Sep 13  2015 lib/
    drwxr-xr-x   2 root root 4096 Jul  6  2016 lib64/
    drwxr-xr-x   2 root root 4096 Jul  6  2016 media/
    drwxr-xr-x   2 root root 4096 Oct 19  2015 mnt/
    drwxr-xr-x   2 root root 4096 Jul  6  2016 opt/
    dr-xr-xr-x 106 root root    0 Jan  7 08:09 proc/
    drwx------   2 root root 4096 Jul  6  2016 root/
    drwxr-xr-x   1 root root 4096 Jan  7 08:09 run/
    drwxr-xr-x   1 root root 4096 Jul 22  2016 sbin/
    drwxr-xr-x   2 root root 4096 Jul  6  2016 srv/
    dr-xr-xr-x  13 root root    0 Apr 11  2018 sys/
    drwxrwxrwt   2 root root 4096 Jul  6  2016 tmp/
    drwxr-xr-x   1 root root 4096 Jul 22  2016 usr/
    drwxr-xr-x   1 root root 4096 Jul 22  2016 var/
    root@13a0527cc2f3:/# cat /proc/version
    Linux version 3.10.0-514.26.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Jul 4 15:04:05 UTC 2017
    root@13a0527cc2f3:/# exit
    exit
    [root@VM_0_9_centos ~]#

    在容器内后台执行一个进程

    [root@VM_0_9_centos ~]# docker run -d ubuntu:15.10 /bin/sh -c "while true; do echo hello world; sleep 1; done"
    6e851b0c97ef533cfae9c5ab7827917efa68a7a845d6c15a65be1b8e3449f16e
    [root@VM_0_9_centos ~]# docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
    6e851b0c97ef        ubuntu:15.10        "/bin/sh -c 'while..."   3 seconds ago       Up 3 seconds                                 compassionate_payne
    ce8ec87e171a        docker-jialong      "sh -c 'java $JAVA..."   20 hours ago        Up 20 hours         0.0.0.0:8080->8080/tcp   laughing_ride
    [root@VM_0_9_centos ~]#
  • 相关阅读:
    UVA12206 Stammering Aliens 【SAM 或 二分 + hash】
    字符串hash
    BZOJ1064 [Noi2008]假面舞会 【dfs】
    BZOJ2333 [SCOI2011]棘手的操作 【离线 + 线段树】
    BZOJ1499 [NOI2005]瑰丽华尔兹 【单调队列优化dp】
    BZOJ3343 & 洛谷2801:教主的魔法——题解
    BZOJ2821:作诗——题解
    BZOJ2724:[Violet 6]蒲公英——题解
    BZOJ2653:middle——题解
    BZOJ2588:Count on a tree——题解
  • 原文地址:https://www.cnblogs.com/hm1250446609/p/12162258.html
Copyright © 2011-2022 走看看