docker-systemd-unpriv, 非特权systemd容器的Docker 文件

分享于 

5分钟阅读

GitHub

  繁體 雙語
Docker files for an unprivileged systemd container
  • 源代码名称:docker-systemd-unpriv
  • 源代码网址:http://www.github.com/maci0/docker-systemd-unpriv
  • docker-systemd-unpriv源代码文档
  • docker-systemd-unpriv源代码下载
  • Git URL:
    git://www.github.com/maci0/docker-systemd-unpriv.git
    Git Clone代码到本地:
    git clone http://www.github.com/maci0/docker-systemd-unpriv
    Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/maci0/docker-systemd-unpriv
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
    docker-systemd-unpriv

    基于 CentOS 7的非特权systemd容器的Docker 文件。

    这里图像旨在作为其他图像的基础。

    要构建它只需执行 ./build.sh

    若要运行容器,只需执行 ./run.sh

    例如:

    
    [root@mwysocki docker-systemd-unpriv]#./build.sh
    
    
    Sending build context to Docker daemon 122.4 kB
    
    
    Sending build context to Docker daemon
    
    
    Step 0 : FROM centos:centos7
    
    
     ---> 7322fbe74aa5
    
    
    Step 1 : MAINTAINER Marcel Wysocki"maci.stgn@gmail.com"
    
    
     ---> Using cache
    
    
     ---> 00c8b93cf714
    
    
    Step 2 : ENV container docker
    
    
     ---> Using cache
    
    
     ---> 9b8f4fb8200a
    
    
    Step 3 : RUN yum -y update; yum clean all
    
    
     ---> Using cache
    
    
     ---> 3345a7b137ca
    
    
    Step 4 : RUN yum -y swap -- remove systemd-container systemd-container-libs -- install systemd systemd-libs dbus
    
    
     ---> Using cache
    
    
     ---> b96655caefbc
    
    
    Step 5 : RUN systemctl mask dev-mqueue.mount dev-hugepages.mount systemd-remount-fs.service sys-kernel-config.mount sys-kernel-debug.mount sys-fs-fuse-connections.mount display-manager.service graphical.target systemd-logind.service
    
    
     ---> Running in 15346731ae25
    
    
     ---> 1ee09b86a67b
    
    
    Removing intermediate container 15346731ae25
    
    
    Step 6 : ADD dbus.service/etc/systemd/system/dbus.service
    
    
     ---> 30046edacbd0
    
    
    Removing intermediate container 84556db3d846
    
    
    Step 7 : RUN systemctl enable dbus.service
    
    
     ---> Running in 151ced2a823e
    
    
     ---> fd86e74cf704
    
    
    Removing intermediate container 151ced2a823e
    
    
    Step 8 : VOLUME/sys/fs/cgroup
    
    
     ---> Running in bd81371550ca
    
    
     ---> 1c888d9613f8
    
    
    Removing intermediate container bd81371550ca
    
    
    Step 9 : VOLUME/run
    
    
     ---> Running in 1bcb2d277021
    
    
     ---> de4f43ca3837
    
    
    Removing intermediate container 1bcb2d277021
    
    
    Step 10 : CMD/usr/lib/systemd/systemd
    
    
     ---> Running in b660c5d8cba6
    
    
     ---> 1d7ff7bdbd64
    
    
    Removing intermediate container b660c5d8cba6
    
    
    Successfully built 1d7ff7bdbd64
    
    
    [root@mwysocki docker-systemd-unpriv]#./run.sh
    
    
    Wed Jul 29 17:11:14 CEST 2015
    
    
    1302a1dbd5ff09e720c566ea6b87f1233f0cc14370022a900bdc84e8d07a27f5
    
    
    To enter docker container run:
    
    
     docker exec -t -i 1302a1dbd5ff09e720c566ea6b87f1233f0cc14370022a900bdc84e8d07a27f5/bin/bash
    
    
    [root@mwysocki docker-systemd-unpriv]# docker exec -t -i 1302a1dbd5ff09e720c566ea6b87f1233f0cc14370022a900bdc84e8d07a27f5/bin/bash
    
    
    [root@1302a1dbd5ff/]# ps -ux
    
    
    USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
    
    
    root 1 0.7 0.0 53584 3328? Ss 15:11 0:00/usr/lib/systemd/systemd
    
    
    root 14 0.1 0.0 43024 5232? Ss 15:11 0:00/usr/lib/systemd/systemd-journald
    
    
    root 24 0.4 0.0 11748 1940? Ss 15:11 0:00/bin/bash
    
    
    root 39 0.0 0.0 19772 1476? R+ 15:11 0:00 ps -ux
    
    
    [root@1302a1dbd5ff/]#
    
    
    
    

    作为替代,你可以获得预先构建的容器: docker pull maci0/systemd 或者只使用默认 Docker 命令( 这应该能自动提取图像) 运行它: docker run -v/sys/fs/cgroup:/sys/fs/cgroup:ro maci0/systemd 有关更多信息,请参见:https://registry.hub.docker.com/u/maci0/systemd/ 或者 http://www.docker.com。


    文件  DOC  SYS  files  系统  Docker  
    相关文章