Difference between revisions of "Docker.io Howto"
From Cactus Howto
Jump to navigationJump to searchLine 83: | Line 83: | ||
Example: |
Example: |
||
sudo docker commit b4360f35202b ubuntu-new |
sudo docker commit b4360f35202b ubuntu-new |
||
== Changing config files == |
|||
RUN sed -i -e "s/^memory_limit\s*=.*/memory_limit = 200M/" /etc/php5/apache2/php.ini |
|||
RUN sed -i -e "s/^max_execution_time\s*=.*/max_execution_time = 900/" /etc/php5/apache2/php.ini |
|||
RUN sed -i -e "s/^default_charset\s*=.*/default_charset = \"utf\-8\"/" /etc/php5/apache2/php.ini |
|||
RUN sed -i -e "s|^include_path\s*=.*|include_path = \"/usr/share/php:/usr/share/lib/php:/usr/share/itsecorg/web/include:/usr/share/itsecorg/etc:/usr/share/itsecorg/web/htdocs/inctxt:/usr/share/itsecorg/web/htdocs/hilfe\"|" /etc/php5/apache2/php.ini |
|||
RUN sed -i -e "s|^doc_root\s*=\s*|doc_root = /usr/share/itsecorg/web|" /etc/php5/apache2/php.ini |
|||
Todo: |
|||
# date.timezone = "Europe/Berlin" |
|||
sql.safe_mode = On |
|||
expose_php = Off |
|||
display_errors = Off ; for production |
|||
display_startup_errors = Off ;for production (both can be switched to On for testing purposes) |
|||
error_log = syslog |
|||
log_errors_max_len = 0 ; abgeschnittene sql-statements beim debugging verhindern |
|||
pgsql.log_notice = 1 |
|||
session.save_path = /var/itsecorg/session |
|||
session.gc_maxlifetime = 14400 ;eight hours |
Revision as of 15:17, 18 November 2014
Basics
A running instance of an image is called container. You can make changes to a container (e.g. delete a file), but these changes will not affect the image. However, you can create a new image from a running container (and all it changes) using docker commit <container-id> <image-name>.
Setup
sample docker running under Ubuntu 14.04.1:
itsecorg@pbuilder:~$ sudo aptitude install docker.io
Set proxy for docker:
itsecorg@pbuilder:~$ grep http_proxy /etc/default/docker.io export http_proxy="http://proxy.int.cactus.de:8080/" sudo service docker.io restart
Image and Container Handling
Search images
sudo docker search -s 4 "ubuntu"
NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Official Ubuntu base image 934 [OK] dockerfile/ubuntu Trusted automated Ubuntu (http://www.ubunt... 32 [OK] crashsystems/gitlab-docker A trusted, regularly updated build of GitL... 21 [OK] ansible/ubuntu14.04-ansible Ubuntu 14.04 LTS with ansible 21 [OK] clue/ttrss The Tiny Tiny RSS feed reader allows you t... 19 [OK] mbentley/ubuntu-django-uwsgi-nginx 17 [OK] sylvainlasnier/memcached Memcached docker images based on Ubuntu 14... 17 [OK] ubuntu-upstart Upstart is an event-based replacement for ... 16 [OK] dockerfile/ubuntu-desktop Trusted automated Ubuntu Desktop (LXDE) (h... 14 [OK] tutum/ubuntu Ubuntu image with SSH access. For the root... 13 [OK] tinyerp/ubuntu-openerp Run OpenERP on Ubuntu - September 2014 10 itsecorg@pbuilder:~$
Install / list / remove images
sudo docker pull ubuntu
Display installed images:
itsecorg@pbuilder:~$ sudo docker images ubuntu REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu utopic 277eb4304907 3 weeks ago 228.5 MB ubuntu 14.10 277eb4304907 3 weeks ago 228.5 MB ubuntu 14.04 5506de2b643b 3 weeks ago 199.3 MB ubuntu 14.04.1 5506de2b643b 3 weeks ago 199.3 MB ubuntu latest 5506de2b643b 3 weeks ago 199.3 MB ubuntu trusty 5506de2b643b 3 weeks ago 199.3 MB ubuntu 12.04 0b310e6bf058 3 weeks ago 126.7 MB ubuntu 12.04.5 0b310e6bf058 3 weeks ago 126.7 MB ubuntu precise 0b310e6bf058 3 weeks ago 126.7 MB ubuntu 12.10 c5881f11ded9 4 months ago 172.2 MB ubuntu quantal c5881f11ded9 4 months ago 172.2 MB ubuntu 13.04 463ff6be4238 4 months ago 169.4 MB ubuntu raring 463ff6be4238 4 months ago 169.4 MB ubuntu 13.10 195eb90b5349 4 months ago 184.7 MB ubuntu saucy 195eb90b5349 4 months ago 184.7 MB ubuntu 10.04 3db9c44f4520 6 months ago 183 MB ubuntu lucid 3db9c44f4520 6 months ago 183 MB itsecorg@pbuilder:~$
Remove
Remove Container
itsecorg@pbuilder:~$ sudo docker rm busybox
Remove Image(s)
itsecorg@pbuilder:~$ sudo docker rmi 0b310e6bf058 c5881f11ded9 463ff6be4238 195eb90b5349 3db9c44f4520
Better:
sudo docker pull ubuntu:14.04.1
itsecorg@pbuilder:~$ sudo docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu 14.04.1 5506de2b643b 3 weeks ago 199.3 MB itsecorg@pbuilder:~$
Show containers
itsecorg@pbuilder:~$ sudo docker ps -a --no-trunc=true itsecorg@pbuilder:~$ sudo docker ps -a --no-trunc=false CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 09a4d97bdc2b ubuntu:14.04.1 sudo http_proxy=http About an hour ago Exited (0) About an hour ago loving_hypatia b4360f35202b ubuntu:14.04.1 sudo http_proxy=http About an hour ago Exited (0) About an hour ago cocky_perlman 8d1fbf98c719 ubuntu:14.04.1 sudo http_proxy=http About an hour ago Exited (0) About an hour ago backstabbing_newton
Create new image from container
Syntax:
sudo docker commit <container-id> <image-name>
Example:
sudo docker commit b4360f35202b ubuntu-new
Changing config files
RUN sed -i -e "s/^memory_limit\s*=.*/memory_limit = 200M/" /etc/php5/apache2/php.ini RUN sed -i -e "s/^max_execution_time\s*=.*/max_execution_time = 900/" /etc/php5/apache2/php.ini RUN sed -i -e "s/^default_charset\s*=.*/default_charset = \"utf\-8\"/" /etc/php5/apache2/php.ini RUN sed -i -e "s|^include_path\s*=.*|include_path = \"/usr/share/php:/usr/share/lib/php:/usr/share/itsecorg/web/include:/usr/share/itsecorg/etc:/usr/share/itsecorg/web/htdocs/inctxt:/usr/share/itsecorg/web/htdocs/hilfe\"|" /etc/php5/apache2/php.ini RUN sed -i -e "s|^doc_root\s*=\s*|doc_root = /usr/share/itsecorg/web|" /etc/php5/apache2/php.ini
Todo:
# date.timezone = "Europe/Berlin" sql.safe_mode = On expose_php = Off display_errors = Off ; for production display_startup_errors = Off ;for production (both can be switched to On for testing purposes) error_log = syslog log_errors_max_len = 0 ; abgeschnittene sql-statements beim debugging verhindern pgsql.log_notice = 1 session.save_path = /var/itsecorg/session session.gc_maxlifetime = 14400 ;eight hours