Docker
Revision as of 12:36, 27 May 2017 by Rafahsolis (talk | contribs) (→Restart stopped container with diferent command)
Install
curl -sSL https://get.docker.com/ | sh
docker pull python:2.7 docker run -i -t python:2.7 docker docker run -i -t python:2.7 bash docker ps -a docker pull linuxkonsult/kali-metasploit docker search kali
docker images
docker run -i -t linuxkonsult/kali-metasploit bash
# Remove all containers
docker rm $(docker ps -aq)
# Remove incompletely built images:
docker images | grep none | awk '{print "docker rmi " $3;}' | sh
Restart stopped container with diferent command
Find your stopped container id
docker ps -a
Commit the stopped container: This command saves modified container state into a new image user/test_image
docker commit $CONTAINER_ID user/test_image
Start/run with a different entry point:
docker run -ti --entrypoint=sh user/test_image
Restart exited container
docker start `docker ps -q -l` # restart it in the background docker attach `docker ps -q -l` # reattach the terminal & stdin
Create & Publish image
mkdir rpi_python nano rpi_python/Dockerfile
Docekerfile
# Pull base image
FROM resin/rpi-raspbian:wheezy
MAINTAINER Dieter Reuter <dieter@hypriot.com>
# Install dependencies
RUN apt-get update && apt-get install -y \
python \
python-dev \
python-pip \
python-virtualenv \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*
# Define working directory
WORKDIR /data
# Define default command
CMD ["bash"]
docker build -t DOCKER_HUB_USERNAME/rpi_python:0.0.1 . # Or with multiple tags docker build -t DOCKER_HUB_USERNAME/rpi_python:0.0.1 -t DOCKER_HUB_USERNAME/rpi_python:latest . # List images docker images # Test image docker run -rm -it DOCKER_HUB_USERNAME/rpi_python:0.0.1 # Login docker login docker push DOCKER_HUB_USERNAME/rpi_python:0.0.1