|
|
在创建docker时添加些参数:4 `( X6 {3 r' w3 P0 D' H4 c# r s! C& B
# docker run --privileged -ti docker.io/centos:7 /usr/sbin/init &
2 L, c- K( R: t6 d$ R# X; `! x) w; E6 \$ I' m
Unable to find image 'centos:7' locally
) F; H' b% a& [; e7: Pulling from library/centos
% ` D8 D: m2 g" k# c/ a0 o4 k7dc0dca2b151: Pull complete 4 s! N& S. e) L, k3 h7 B S5 b
Digest: sha256:b67d21dfe609ddacf404589e04631d90a342921e81c40aeaf3391f6717fa5322
8 h5 ]5 e* [6 C, r J' mStatus: Downloaded newer image for centos:7, g' Z0 i4 m6 j) {$ b* ^% Z4 x
" @: \* g* d7 L* X4 s) i
5 y' i6 x. k H2 ]/ {1 @
. e0 S" `& }$ B! b; _1 P. F# docker run --privileged -it centos /usr/sbin/init
. T" @( a( q% [/ e+ L3 BUnable to find image 'centos:latest' locally" Y1 x+ C6 F# v$ x" P5 h
latest: Pulling from library/centos
0 h8 ~, z( a, j! {+ y/ h7dc0dca2b151: Pull complete 0 \+ p2 b/ h4 E0 W7 [0 L+ q
Digest: sha256:b67d21dfe609ddacf404589e04631d90a342921e81c40aeaf3391f6717fa53225 c7 ]3 y& w. N! b7 e$ |
Status: Downloaded newer image for centos:latest) ~/ i& Q, X# L; u7 y
% u1 E" n; m9 Z3 c; [进入到docker容器中,安装httpd软件,并启动httpd服务。9 u C' Q; a- {$ A
# docker exec -it dcb5c79348a0 /bin/bash
1 ?' [ n8 q" H4 }* H. f) e. S. |, {7 w7 a
[root@dcb5c79348a0 /]# systemctl start httpd: B9 b/ M+ X( L1 l9 a
[root@dcb5c79348a0 /]# systemctl status httpd.service
8 W+ V6 [: f5 L+ S5 T● httpd.service - The Apache HTTP Server
3 M$ E) i1 J ?7 ? Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled); D Z; Y# T2 K4 y: e
Active: active (running) since Thu 2018-06-21 07:38:03 UTC; 11s ago
; m4 o" T7 Q4 W' @ Docs: man:httpd(8)
9 L f8 O! F" z k! h$ {6 K man:apachectl(8)
5 P) Y; W$ ]: [5 s/ h Main PID: 199 (httpd)* B# G2 p+ o' l" `: u$ S; i* _
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
7 k5 g' k% d O CGroup: /docker/dcb5c79348a0ba92f0ccf225e2f9c42810b6f8ad7884400a968c767ae5569694/system.slice/httpd.service
$ b1 h" M5 l% t9 [ ├─199 /usr/sbin/httpd -DFOREGROUND
Z* d! z* h* _$ U1 s- X5 a$ Z' }. P ├─200 /usr/sbin/httpd -DFOREGROUND# t1 F2 L7 j4 i( P# m: L6 i
├─201 /usr/sbin/httpd -DFOREGROUND
! H4 d; K$ X* A# Y. z: N ├─202 /usr/sbin/httpd -DFOREGROUND
) s2 r% {' v# g. {" I% k' T ├─203 /usr/sbin/httpd -DFOREGROUND
& ]# n5 D( t+ }+ e% S# s' a └─204 /usr/sbin/httpd -DFOREGROUND
3 o6 n! i3 d/ i( O2 d ‣ 199 /usr/sbin/httpd -DFOREGROUND7 N2 q/ |# t* U9 n% d0 ^7 B
( P4 `9 u) W5 x1 @8 E4 v: k, ]+ |
Jun 21 07:38:03 dcb5c79348a0 systemd[1]: Starting The Apache HTTP Server...6 E' T7 \5 m/ S( q; w& R. U
Jun 21 07:38:03 dcb5c79348a0 httpd[199]: AH00558: httpd: Could not reliably ...e
% h M o# M4 q; N5 CJun 21 07:38:03 dcb5c79348a0 systemd[1]: Started The Apache HTTP Server.
1 N T; v+ t' [! oHint: Some lines were ellipsized, use -l to show in full.
3 d8 ~( `+ G `" n [9 X |
|