docker和centos你需要知道的
2016-07-08 14:51
901 查看
https://hub.docker.com/_/centos/
docker pull centos:6
docker pull centos:6.6
yum:
注释掉 /etc/yum.conf 中tsflags=modocs,重装包
systemd for centos 7系
#systemd 包含在centos:7和centos:latest中,默认没有激活
Dockerfile for sytemd base image
FROM centos:7
MAINTAINER "you" <your@email.here>
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i ==
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]
docker build --rm -t local/c7-systemd .
systemd enabled app container
FROM local/c7-systemd
RUN yum -y install httpd; yum clean all; systemctl enable httpd.service
EXPOSE 80
CMD ["/usr/sbin/init"]
$ docker build --rm -t local/c7-systemd-httpd
run a systemd enabled container
In order to run a container with systemd, you will need to mount the cgroups volumes from the host. Below is an example command that will run the systemd enabled httpd container created earlier.
docker pull centos:6
docker pull centos:6.6
yum:
注释掉 /etc/yum.conf 中tsflags=modocs,重装包
systemd for centos 7系
#systemd 包含在centos:7和centos:latest中,默认没有激活
Dockerfile for sytemd base image
FROM centos:7
MAINTAINER "you" <your@email.here>
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i ==
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]
docker build --rm -t local/c7-systemd .
systemd enabled app container
FROM local/c7-systemd
RUN yum -y install httpd; yum clean all; systemctl enable httpd.service
EXPOSE 80
CMD ["/usr/sbin/init"]
$ docker build --rm -t local/c7-systemd-httpd
run a systemd enabled container
In order to run a container with systemd, you will need to mount the cgroups volumes from the host. Below is an example command that will run the systemd enabled httpd container created earlier.
$ docker run -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 80:80 local/c7-systemd-httpd
相关文章推荐
- centos6.5上安装docker
- Centos6 编译安装Python
- docker容器的网络信息查看
- 硬盘安装CentOS 6.2以及添加GRUB启动菜单
- CentOS 6.2实战部署Nginx+MySQL+PHP
- CentOS 7系统配置上的变化解析
- openstack kilo-with-dokcer
- CentOS下DB2数据库安装过程详解
- CentOS 6.3下编译安装Ruby 2.0笔记
- 在windows下的安装Docker的教程
- 8个你可能不知道的Docker知识
- 在Centos 5.5 上编译安装mysql 5.5.9
- 在阿里云的CentOS环境中安装配置MySQL的教程
- CentOS 6.5源码安装Erlang教程
- Centos下安装docker教程
- 在CenOS系统下安装和配置Redis数据库的教程
- centos 5.6 升级php到5.3的方法
- CentOS mysql安装系统方法