我們需要給docker傳人更多的參數(shù),以便讓systemd在容器中運(yùn)行:
doker run -it -m -v /sys/foup: /ys/fcgroup: o —v 'pd.'/
sible :/ansible<hash>
容器用systemd啟動(dòng),現(xiàn)在我們需要從一個(gè)不同的shell命令行連接運(yùn)行著的容器
Docker exec -it <hash>bash
我的媽呀,為了讓容器運(yùn)行得更加逼真我們也真是耗盡心力。不過(guò)換句話說(shuō),用虛擬
機(jī)的方式,如VirtualBox,在我看來(lái)更加麻煩。當(dāng)然讀者也許不會(huì)這么覺(jué)得。現(xiàn)在,我們
可以在容器中運(yùn)行一個(gè)更加復(fù)雜的Ansible playbook,如下所示:
- hosts : localhost
vars
http_port : 80
max clients : 200
remote user: root
tasks :
- name: ensure apache is at the latest version
yum: namehttpd state'-latest
- name: write the apache config file
template : src=/srv/httpd. j2 dest=/etc/httpd.conf
notify:
- restart apache
- name: ensure apache is running (and enable it at boot)
service : namehttpd state=started enabledyes
handlers :
- name: restart apache
service : namehttpd state=restarted
這個(gè)例子在前面的基礎(chǔ)上構(gòu)建,并且告訴你如何
* 安裝包。
* 編寫一個(gè)模板文件。
* 處理一個(gè)服務(wù)的運(yùn)行狀態(tài)。
%* 格式為非常簡(jiǎn)單的YML語(yǔ)法。