Unix Container: Difference between revisions
Jump to navigation
Jump to search
Line 38: | Line 38: | ||
<pre>docker stop $(docker ps -a -q) | <pre>docker stop $(docker ps -a -q) | ||
docker rm $(docker ps -a -q)</pre> | docker rm $(docker ps -a -q)</pre> | ||
==More Advence Topics== | |||
===Build an image from a Dockerfile=== | |||
<pre>docker build /path to/Dockerfile</pre> | |||
<pre>docker build -t [username]/docker-desktop git://github.com/rogaha/docker-desktop.git</pre> | |||
===Execute more advances=== | ===Execute more advances=== | ||
<pre>docker run -i -t --net="bridge" --name Demo -v /opt/docker/data mindesktop:v01.01</pre> | <pre>docker run -i -t --net="bridge" --name Demo -v /opt/docker/data mindesktop:v01.01</pre> | ||
===Dockerfile Sample=== | |||
====node Js==== | |||
<pre> | |||
FROM komljen/ubuntu | |||
MAINTAINER Alen Komljen <alen.komljen@live.com> | |||
RUN \ | |||
add-apt-repository -y ppa:chris-lea/node.js && \ | |||
apt-get update && \ | |||
apt-get -y install \ | |||
nodejs && \ | |||
rm -rf /var/lib/apt/lists/* | |||
</pre> | |||
====Ghost (Blog Server)==== | |||
<pre> | |||
FROM komljen/nodejs | |||
MAINTAINER Alen Komljen <alen.komljen@live.com> | |||
ENV GHOST_VERSION 0.5.7 | |||
ENV APP_ROOT /data/app | |||
RUN \ | |||
curl -sLO http://ghost.org/archives/ghost-${GHOST_VERSION}.zip && \ | |||
mkdir -p ${APP_ROOT} && \ | |||
unzip -uo ghost-${GHOST_VERSION}.zip -d ${APP_ROOT} && \ | |||
rm ghost-${GHOST_VERSION}.zip | |||
RUN \ | |||
cd ${APP_ROOT} && \ | |||
npm install --production | |||
ADD start.sh start.sh | |||
VOLUME ["$APP_ROOT"] | |||
RUN rm /usr/sbin/policy-rc.d | |||
CMD ["/start.sh"] | |||
EXPOSE 2368 | |||
</pre> |
Revision as of 17:33, 29 March 2015
Container Howto
Install and run a container
docker run -i -t ubuntu:14:04 /bin/bash
Create an image from a container Commit
"b5673dbced61" is an image id
docker commit -m "Ubuntu 14.10 Demonstrator" -a "Author Name" b5673dbced61 demo:14.10
List Images (Source to initiare a containers)
docker images
Remove an image "b5673dbced61" is an image id
docker rmi b5673dbced61
List containers (Running Virtual Machines)
- Running:
docker ps
- Full List
docker ps -a
Start and Stop a container
- Stop
docker stop "containerId or Name"
- Start (Batch)
docker start "containerId or Name"
- Start (and login in)
docker start -i "containerId or Name"
"Relogin" (Attach) into a Container
- "Relogin into a running container
docker attach "container Name"
Remove a container
"d0955f21bf24" is a container Id
docker rm d0955f21bf24
Remove all containers
docker stop $(docker ps -a -q) docker rm $(docker ps -a -q)
More Advence Topics
Build an image from a Dockerfile
docker build /path to/Dockerfile
docker build -t [username]/docker-desktop git://github.com/rogaha/docker-desktop.git
Execute more advances
docker run -i -t --net="bridge" --name Demo -v /opt/docker/data mindesktop:v01.01
Dockerfile Sample
node Js
FROM komljen/ubuntu MAINTAINER Alen Komljen <alen.komljen@live.com> RUN \ add-apt-repository -y ppa:chris-lea/node.js && \ apt-get update && \ apt-get -y install \ nodejs && \ rm -rf /var/lib/apt/lists/*
Ghost (Blog Server)
FROM komljen/nodejs MAINTAINER Alen Komljen <alen.komljen@live.com> ENV GHOST_VERSION 0.5.7 ENV APP_ROOT /data/app RUN \ curl -sLO http://ghost.org/archives/ghost-${GHOST_VERSION}.zip && \ mkdir -p ${APP_ROOT} && \ unzip -uo ghost-${GHOST_VERSION}.zip -d ${APP_ROOT} && \ rm ghost-${GHOST_VERSION}.zip RUN \ cd ${APP_ROOT} && \ npm install --production ADD start.sh start.sh VOLUME ["$APP_ROOT"] RUN rm /usr/sbin/policy-rc.d CMD ["/start.sh"] EXPOSE 2368