Skip to content

Instantly share code, notes, and snippets.

@amitsaha
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitsaha/713c7603e3c143329d4d to your computer and use it in GitHub Desktop.
Save amitsaha/713c7603e3c143329d4d to your computer and use it in GitHub Desktop.
docker tips

Basics

Create a container with an interactive shell: docker run -t fedora -i /bin/bash

# make changes (install a server)

commit using docker commit <container id>

# run a server program and expose

# host: 9090, container: 90

docker run -d -p 9090:80 random/apache /usr/sbin/httpd -D FOREGROUND

Cleanup

  • Images: docker rmi `docker images -q`
  • Containers: docker rmi $(docker ps -a -q)

Building a Fedora base image (and build upon it)

Notes: http://allthingsopen.com/2013/12/19/building-docker-images-on-fedora/

virt-tar-out -a /tmp/myimages/fedora-image/fedora-image-sda.qcow2 / - | docker import - testing/f20-base

docker tag b385392d1aab localhost.localdomain:5000/f20-base docker push localhost.localdomain:5000/f20-base

$ cat Dockerfile FROM localhost.localdomain:5000/f20-base MAINTAINER echo@echorand.com

RUN yum -y install python3

ENV LANG C CMD ["/bin/bash"][asaha@dhcp-40-115 fed cat Dockerfile FROM localhost.localdomain:5000/f20-base MAINTAINER echo@echorand.com

RUN yum -y install python3

ENV LANG C CMD ["/bin/bash"]

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment