Changes

Jump to navigation Jump to search
648 bytes added ,  14:35, 25 March 2019
m
Line 1: Line 1: −
= Install =
+
=Install=
 
[https://docs.docker.com/install/linux/docker-ce/ubuntu/ Docker-CE]<br />
 
[https://docs.docker.com/install/linux/docker-ce/ubuntu/ Docker-CE]<br />
[https://docs.docker.com/compose/install/ Docker-compose]<br />
+
[https://docs.docker.com/compose/install/ Docker-compose]<br />
   −
<source lang="bash">sudo apt-get remove docker docker-engine docker.io
+
<source lang="bash">sudo apt-get remove docker docker-engine docker.io
 
sudo apt-get update
 
sudo apt-get update
 
sudo apt-get install    apt-transport-https    ca-certificates    curl    software-properties-common
 
sudo apt-get install    apt-transport-https    ca-certificates    curl    software-properties-common
Line 21: Line 21:  
### old: curl -sSL https://get.docker.com/ | sh</source>
 
### old: curl -sSL https://get.docker.com/ | sh</source>
   −
== Docker Swarm ==
+
==Docker Swarm==
 
  <nowiki>docker swarm init --advertise-addr=<IP-ADDRESS-OF-MANAGER>
 
  <nowiki>docker swarm init --advertise-addr=<IP-ADDRESS-OF-MANAGER>
docker network create -d overlay nginx-proxy
+
docker network create -d overlay nginx-proxy
docker pull postgres:10.6 && docker pull redis:3.2-alpine && docker pull jwilder/nginx-proxy</nowiki>
+
docker pull postgres:10.6 && docker pull redis:3.2-alpine && docker pull jwilder/nginx-proxy</nowiki>
 
   
 
   
== Examples ==
+
==Examples==
 
  docker pull python:2.7
 
  docker pull python:2.7
 
  docker run -i -t python:2.7
 
  docker run -i -t python:2.7
Line 46: Line 46:  
  docker images | grep -v IMAGE\ ID | awk '{print "docker rmi " $3;}'
 
  docker images | grep -v IMAGE\ ID | awk '{print "docker rmi " $3;}'
   −
= Restart stopped container with diferent command =
+
=Restart stopped container with diferent command=
 
Find your stopped container id
 
Find your stopped container id
 
  docker ps -a
 
  docker ps -a
Line 55: Line 55:  
  docker run -ti --entrypoint=sh user/test_image
 
  docker run -ti --entrypoint=sh user/test_image
   −
== Restart exited container ==
+
==Restart exited container==
 
  docker start  `docker ps -q -l` # restart it in the background
 
  docker start  `docker ps -q -l` # restart it in the background
 
  docker attach `docker ps -q -l` # reattach the terminal & stdin
 
  docker attach `docker ps -q -l` # reattach the terminal & stdin
   −
== Create & Publish image ==
+
==Create & Publish image==
 
  mkdir rpi_python
 
  mkdir rpi_python
 
  nano rpi_python/Dockerfile
 
  nano rpi_python/Dockerfile
Line 65: Line 65:  
Docekerfile
 
Docekerfile
 
  <nowiki># Pull base image
 
  <nowiki># Pull base image
FROM resin/rpi-raspbian:wheezy
+
FROM resin/rpi-raspbian:wheezy
MAINTAINER Dieter Reuter <dieter@hypriot.com>
+
MAINTAINER Dieter Reuter <dieter@hypriot.com>
 
+
# Install dependencies
+
# Install dependencies
RUN apt-get update && apt-get install -y \
+
RUN apt-get update && apt-get install -y \
    python \
+
    python \
    python-dev \
+
    python-dev \
    python-pip \
+
    python-pip \
    python-virtualenv \
+
    python-virtualenv \
    --no-install-recommends && \
+
    --no-install-recommends && \
    rm -rf /var/lib/apt/lists/*
+
    rm -rf /var/lib/apt/lists/*
 
+
# Define working directory
+
# Define working directory
WORKDIR /data
+
WORKDIR /data
 
+
# Define default command
+
# Define default command
CMD ["bash"]</nowiki>
+
CMD ["bash"]</nowiki>
    
  docker build -t DOCKER_HUB_USERNAME/rpi_python:0.0.1 .
 
  docker build -t DOCKER_HUB_USERNAME/rpi_python:0.0.1 .
Line 94: Line 94:  
  docker push DOCKER_HUB_USERNAME/rpi_python:0.0.1
 
  docker push DOCKER_HUB_USERNAME/rpi_python:0.0.1
   −
=== Pull Modify Commit ===
+
===Pull Modify Commit===
    
  <nowiki>210
 
  <nowiki>210
down vote
+
down vote
accepted
+
accepted
+
 
+
You need to commit the changes you make to the container and then run it. Try this:
+
You need to commit the changes you make to the container and then run it. Try this:
 
+
sudo docker pull ubuntu
+
sudo docker pull ubuntu
 +
 +
sudo docker run ubuntu apt-get install -y ping
 +
 +
Then get the container id using this command:
 +
 +
sudo docker ps -l
 +
 +
Commit changes to the container:
 +
 +
sudo docker commit <container_id> iman/ping
 +
 +
Then run the container:
 +
 +
sudo docker run iman/ping ping www.google.com</nowiki>
   −
sudo docker run ubuntu apt-get install -y ping
+
== Docker mirror ==
 +
<syntaxhighlight lang="bash">
 +
#!/bin/bash
   −
Then get the container id using this command:
+
# PULL
 +
docker login gitrra.dyndns.org:4443
 +
docker login git.rra.lan:4443
   −
sudo docker ps -l
+
FROM=gitrra.dyndns.org:4443/rra/pdgrt/deployment/
 +
TO=git.rra.lan:4443/pdgrt_2.0_mirror/deployment/
   −
Commit changes to the container:
+
REPOS="pdgrt-central-frontend pdgrt-proxy-frontend pdgrt-node-frontend pdgrt-proxy-backend/django pdgrt-proxy-backend/nginx pdgrt-node-backend/django pdgrt-node-backend/nginx pdgrt-central-backend/django pdgrt-central-backend/nginx"
   −
sudo docker commit <container_id> iman/ping
     −
Then run the container:
+
for repo in ${REPOS}; do
 +
    docker pull ${FROM}${repo}
 +
    docker tag ${FROM}${repo} ${TO}${repo}
 +
    docker push ${TO}${repo}
 +
done
   −
sudo docker run iman/ping ping www.google.com</nowiki>
+
</syntaxhighlight>
   −
== Dockerfile reference ==
+
==Dockerfile reference==
 
https://docs.docker.com/engine/reference/builder/
 
https://docs.docker.com/engine/reference/builder/

Navigation menu