Difference between revisions of "Docker Image for developing"

From ESS-WIKI
Jump to: navigation, search
Line 3: Line 3:
 
<span style="font-size:large;">'''Docker Run - runs processes in isolated container&nbsp;[https://docs.docker.com/engine/reference/run/ option]'''</span>
 
<span style="font-size:large;">'''Docker Run - runs processes in isolated container&nbsp;[https://docs.docker.com/engine/reference/run/ option]'''</span>
  
*
+
*-d&nbsp;: background service
-d : background service
 
 
 
 
*-it:: For interactive processes ( like a shell).
 
*-it:: For interactive processes ( like a shell).
 
*--name:&nbsp;Container identification
 
*--name:&nbsp;Container identification
 
*-p: export port&nbsp; e.g &lt;host port&gt;:&lt;internal port&gt;&nbsp; &nbsp; 80:3000
 
*-p: export port&nbsp; e.g &lt;host port&gt;:&lt;internal port&gt;&nbsp; &nbsp; 80:3000
 
*exec: run a command in a running container
 
*exec: run a command in a running container
*-v : volume ( shared filesystems ) e.g. -v [host-src]:[container-dest]:[option]&nbsp; -v /run/udev:/run/udev:ro, -v $PWD:/home/adv:rw
+
*-v&nbsp;: volume ( shared filesystems ) e.g. -v [host-src]:[container-dest]:[option]&nbsp; -v /run/udev:/run/udev:ro, -v $PWD:/home/adv:rw
*--privileged :&nbsp;Docker will enable access to all devices on the host as well as set some configuration in AppArmor or SELinux to allow the container nearly all the same access to the host as processes running outside containers on the host
+
*--privileged&nbsp;:&nbsp;Docker will enable access to all devices on the host as well as set some configuration in AppArmor or SELinux to allow the container nearly all the same access to the host as processes running outside containers on the host
  
 
<span style="font-size:large;">'''Start a docker container and export server port'''</span>
 
<span style="font-size:large;">'''Start a docker container and export server port'''</span>

Revision as of 07:55, 12 September 2018

Common Docker CLI

Docker Run - runs processes in isolated container option

  • -d : background service
  • -it:: For interactive processes ( like a shell).
  • --name: Container identification
  • -p: export port  e.g <host port>:<internal port>    80:3000
  • exec: run a command in a running container
  • -v : volume ( shared filesystems ) e.g. -v [host-src]:[container-dest]:[option]  -v /run/udev:/run/udev:ro, -v $PWD:/home/adv:rw
  • --privileged : Docker will enable access to all devices on the host as well as set some configuration in AppArmor or SELinux to allow the container nearly all the same access to the host as processes running outside containers on the host

Start a docker container and export server port

MQTT BUS

sudo docker run -d -it --name advigw-mqtt-bus -p 1883:1883 advigw4x86/mqtt-bus

API-Gateway

sudo docker run -d -it --name advigw-api-gw -p 3000:3000 advigw4x86/api-gw


Start a docker container and enter into bash

// need add -it
// Run and enter to bash
$sudo docker run -d -it --name advigw-wisesnail-lib-dev -v $PWD:/home/adv/workspace:rw advigw4x86/wisesnail-lib /bin/bash 
// Enter a running container bash
$sudo docker exec -it advigw-wisesnail-lib-dev bash


Stop / Start Docker Container

WSN Simulator

$sudo docker stop advigw-wsn-simulator

$sudo docker start advigw-wsn-simulator

Network Configuration in Docker Container

 sudo docker network create -d bridge --subnet 172.25.0.0/16 advigw_network
 
 sudo docker network connect advigw_network advigw-mqtt-bus
 
 sudo docker network connect advigw_network advigw-api-gw
 
 sudo docker network connect advigw_network advigw-wisesnail-lib-dev

 sudo docker network connect advigw_network advigw-wsn-simulator


How to create a Auto Build project on Docker hub with GitHub

Docker for Windows Hyper-V

https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-networking


https://docs.microsoft.com/zh-tw/virtualization/windowscontainers/manage-containers/container-networking