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 ~]#
  • 相关阅读:
    mybatis-generator自动生成代码时,只生成insert方法
    elasticsearch-head-master下运行npm install报npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression
    fs.default.name和fs.defaultFS
    zookeeper集群为什么要是单数
    Quorom机制
    把数据库放入Docker是一个好主意吗?
    JVM GC算法CMS详解
    JVM之——CMS
    对于TCP/IP协议的三次握手和四次挥手的理解
    JVM G1和CMS
  • 原文地址:https://www.cnblogs.com/hm1250446609/p/12162258.html
Copyright © 2011-2022 走看看