Changes

Jump to navigation Jump to search
72 bytes added ,  14:40, 25 March 2019
m
Line 22: Line 22:     
==Docker Swarm==
 
==Docker Swarm==
<source lang=bash>docker swarm init --advertise-addr=<IP-ADDRESS-OF-MANAGER>
+
<source lang="bash">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</source>
 
  docker pull postgres:10.6 && docker pull redis:3.2-alpine && docker pull jwilder/nginx-proxy</source>
 
   
 
   
 
==Examples==
 
==Examples==
<source lang=bash>docker pull python:2.7
+
<source lang="bash">docker pull python:2.7
 
docker run -i -t python:2.7
 
docker run -i -t python:2.7
 
docker docker run -i -t python:2.7 bash
 
docker docker run -i -t python:2.7 bash
Line 48: Line 48:  
=Restart stopped container with diferent command=
 
=Restart stopped container with diferent command=
 
Find your stopped container id
 
Find your stopped container id
<source lang=bash>docker ps -a</source>
+
<source lang="bash">docker ps -a</source>
 
Commit the stopped container:
 
Commit the stopped container:
 
This command saves modified container state into a new image user/test_image
 
This command saves modified container state into a new image user/test_image
<source lang=bash>docker commit $CONTAINER_ID user/test_image</source>
+
<source lang="bash">docker commit $CONTAINER_ID user/test_image</source>
 
Start/run with a different entry point:
 
Start/run with a different entry point:
<source lang=bash>docker run -ti --entrypoint=sh user/test_image</source>
+
<source lang="bash">docker run -ti --entrypoint=sh user/test_image</source>
    
==Restart exited container==
 
==Restart exited container==
<source lang=bash>docker start  `docker ps -q -l` # restart it in the background
+
<source lang="bash">docker start  `docker ps -q -l` # restart it in the background
 
docker attach `docker ps -q -l` # reattach the terminal & stdin</source>
 
docker attach `docker ps -q -l` # reattach the terminal & stdin</source>
    
==Create & Publish image==
 
==Create & Publish image==
<source lang=bash>mkdir rpi_python
+
<nowiki><source lang=bash>mkdir rpi_python</nowiki>
nano rpi_python/Dockerfile<source lang=bash>
+
nano rpi_python/Dockerfile<nowiki></source></nowiki>
    
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 97: Line 97:     
  <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
+
  sudo docker run ubuntu apt-get install -y ping
+
 
Then get the container id using this command:
+
  Then get the container id using this command:
+
 
sudo docker ps -l
+
  sudo docker ps -l
+
 
Commit changes to the container:
+
  Commit changes to the container:
+
 
sudo docker commit <container_id> iman/ping  
+
  sudo docker commit <container_id> iman/ping  
+
 
Then run the container:
+
  Then run the container:
+
 
sudo docker run iman/ping ping www.google.com</nowiki>
+
  sudo docker run iman/ping ping www.google.com</nowiki>
   −
== Docker mirror ==
+
==Docker mirror==
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
#!/bin/bash
 
#!/bin/bash

Navigation menu