You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FROM centos:centos6.7
MAINTAINER Sean McGuigan <[email protected]>
RUN yum -y update; yum clean all
RUN yum -y install httpd
RUN echo "Docker Test Site" >> /var/www/html/index.html
EXPOSE 80
RUN echo "/sbin/service httpd start" >> /root/.bashrc
map random ports on your docker host above 49000 to port 80 within your web server containers.
docker run -i -t -d -P seanmc:httpd /bin/bash
6acf86f1774d seanmc:httpd "/bin/bash" 7 seconds ago Up 6 seconds 0.0.0.0:32769->80/tcp berserk_hoover
five Useful Docker CLI Commands
copy from container directory
docker cp container_name:/etc/yum.conf /tmp
diff container changes on top of base image
docker diff mywebshit
C /var
C /var/log
C /var/log/httpd
A /var/log/httpd/error_log
A /var/log/httpd/access_log
C /var/run
C /var/run/httpd
A /var/run/httpd/httpd.pid
C /var/lock
C /var/lock/subsys
A /var/lock/subsys/httpd
C = changed
A = added
D = deleted
system events when creating containers, like tailing logs
docker events
view events time window
docker events --since 2016-07-07
history of an image
docker history seanmcguigan/centos6.7:tomcat6
IMAGE CREATED CREATED BY SIZE COMMENT
60204d32c705 5 weeks ago /bin/bash 377.7 MB
23f282322497 5 weeks ago /bin/sh -c echo "/sbin/service httpd start" > 202 B
1a4d382db904 5 weeks ago /bin/sh -c #(nop) EXPOSE 80/tcp 0 B
ee9d95ae4571 5 weeks ago /bin/sh -c echo "Docker Test Site" >> /var/ww 17 B
c2da9bac78d6 5 weeks ago /bin/sh -c yum -y install java 181.1 MB
71c2b35a4684 6 weeks ago /bin/sh -c yum -y install httpd 115.2 MB
d7d829c9a59e 6 weeks ago /bin/sh -c yum -y update; yum clean all 191.7 MB
c352e3942654 6 weeks ago /bin/sh -c #(nop) MAINTAINER Sean McGuigan <s 0 B
3fba1048142f 8 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0 B
b89573a5b116 8 months ago /bin/sh -c #(nop) LABEL License=GPLv2 0 B
8e6730e0eaef 8 months ago /bin/sh -c #(nop) LABEL Vendor=CentOS 0 B
5fc6f5013018 8 months ago /bin/sh -c #(nop) ADD file:63df1fe23f2f72b766 190.6 MB
47d44cb6f252 10 months ago /bin/sh -c #(nop) MAINTAINER The CentOS Proje 0 B
execute commands inside a running container
run a container
docker run -d -it --name foobar seanmc:java /bin/bash
^ ^
container image used by container
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d365ce86e6b8 seanmc:java "/bin/bash" 7 seconds ago Up 6 seconds 80/tcp foobar
docker exec -it foobar /usr/bin/yum repolist
zcat my_container.tgz | docker import - my_new_image <- lower case
set dns
docker run -it --dns=8.8.8.8 --name="mycontainer1" docker.io/ubuntu:latest /bin/bash
docker run -it --dns=8.8.8.8 --dns-search="mydomain.local" --name="mycontainer2"
docker run -it --dns=8.8.8.8 --dns-search="mydomain.local" --name="mycontainer3" -v /local_vol -v /home/tcox/docker/mydata:/remote_vol docker.io/ubuntu:latest /bin/bash
start services on (boot) start
cat ~/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
/sbin/service httpd start
/sbin/service openssh-server start