Skip to content

Commit

Permalink
Fix Yeoman's permission issue in Linux container (#313)
Browse files Browse the repository at this point in the history
* Fix dockerfile

* Fix dockerfile issues

* Switch to iotedgedev and require sudo for Docker commands
  • Loading branch information
LazarusX authored Sep 4, 2018
1 parent c78700e commit 2fc7b1e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docker/runtime/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Set the connection string to the IoT Edge device you want to connect to in the `

Create and set the enviroment variable IOT_DEVICE_CONNSTR to your IoT Edge Device connection string.

Execute the `run-container.ps1` file. A container named `iotedgec` will be created and inside the `iotedged` daemon will be started. If everything is working correctly you will see the deamon output log.
Execute the `run-container.ps1` file. A container named `iotedgec` will be created and inside the `iotedged` daemon will be started. If everything is working correctly you will see the daemon output log.

The deamon will use the default ip address assigned by Docker to the container (most probably will be 172.17.0.2). The discovery is automatically done in the `rund.sh` script. If you have changed your Docker network configuration this script may not work as expected, as it looks specifically for `eth0`.
The daemon will use the default ip address assigned by Docker to the container (most probably will be 172.17.0.2). The discovery is automatically done in the `rund.sh` script. If you have changed your Docker network configuration this script may not work as expected, as it looks specifically for `eth0`.

### Use IoT Edge CLI

Expand Down
8 changes: 7 additions & 1 deletion docker/tool/linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ ARG IOTEDGEDEV_VERSION
COPY iotedgedev-$IOTEDGEDEV_VERSION-py2.py3-none-any.whl dist/iotedgedev-$IOTEDGEDEV_VERSION-py2.py3-none-any.whl
RUN pip install dist/iotedgedev-$IOTEDGEDEV_VERSION-py2.py3-none-any.whl
RUN export LC_ALL=C.UTF-8 && \
export LANG=C.UTF-8
export LANG=C.UTF-8

RUN useradd -m iotedgedev && \
echo 'iotedgedev ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
chown -R iotedgedev:iotedgedev .

USER iotedgedev
11 changes: 8 additions & 3 deletions docker/tool/linux/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ ENV DEBIAN_FRONTEND noninteractive
ENV DOTNETCORESDK_VERSION 2.1.200
ENV DOCKER_COMPOSE_VERSION 1.22.0
RUN apt-get update
RUN apt-get install gnupg gnupg2 gnupg1 -y && \
apt-get install -y --no-install-recommends dialog apt-utils curl apt-transport-https python-pip python3-pip libltdl-dev docker.io && \
RUN apt-get install -y apt-transport-https ca-certificates curl software-properties-common && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \
apt-get update && \
apt-get install -y docker-ce
RUN apt-get install git gnupg gnupg2 gnupg1 -y && \
apt-get install -y --no-install-recommends dialog apt-utils curl apt-transport-https python-pip python3-pip libltdl-dev && \
curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
apt-get install -y nodejs
RUN apt-get install -y wget && \
Expand All @@ -25,7 +30,7 @@ RUN AZ_REPO=$(lsb_release -cs) && \
RUN apt-get update && az extension add --name azure-cli-iot-ext && \
npm i npm@latest -g && \
npm i -g iothub-explorer yo generator-azure-iot-edge-module && \
apt-get install -y --no-install-recommends python-dev build-essential libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev && \
apt-get install -y --no-install-recommends python-dev build-essential libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev sudo && \
rm -rf /var/lib/apt/lists/*
RUN python -m pip install --upgrade pip && \
alias python=python3 && \
Expand Down
10 changes: 9 additions & 1 deletion docker/tool/windows/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ARG PYTHON3_VERSION
ENV NODEJS_VERSION 8.11.1
ENV DOTNETCORESDK_VERSION 2.1.4
ENV DOCKER_VERSION 17.09.0
ENV GIT_VERSION 2.18.0
ENV DESTINATION_FOLDER C:\\tools
WORKDIR /tmp
RUN $python_url = ('https://www.python.org/ftp/python/{0}/python-{0}.amd64.msi' -f $env:PYTHON2_VERSION); \
Expand Down Expand Up @@ -40,6 +41,13 @@ RUN $docker_url = ('https://download.docker.com/win/static/stable/x86_64/docker-
$install_folder = Join-Path -Path $env:DESTINATION_FOLDER -ChildPath ''; \
Expand-Archive -Path .\docker.zip -DestinationPath $install_folder; \
Remove-Item ('{0}\docker\dockerd.exe' -f $env:DESTINATION_FOLDER)
RUN $git_url = ('https://github.com/git-for-windows/git/releases/download/v{0}.windows.1/MinGit-{0}-64-bit.zip' -f $env:GIT_VERSION); \
Write-Host ('Downloading {0}...' -f $git_url); \
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
(New-Object System.Net.WebClient).DownloadFile($git_url, '/tmp/git.zip'); \
$unpack_folder = Join-Path -Path $env:DESTINATION_FOLDER -ChildPath 'git'; \
Write-Host ('Unpacking into {0}...' -f $unpack_folder); \
Expand-Archive .\git.zip -DestinationPath $unpack_folder;

FROM microsoft/nanoserver:1709
RUN mkdir c:\\tools
Expand All @@ -48,7 +56,7 @@ USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\tools\dotnetcoresdk;C:\tools\node\;C:\tools\python3;C:\tools\python3\Scripts;c:\tools\docker\;"
USER ContainerUser
RUN python -m pip install --upgrade pip
RUN pip install azure-cli cookiecutter
RUN pip install azure-cli cookiecutter docker-compose
RUN npm i -g iothub-explorer yo generator-azure-iot-edge-module
RUN az extension add --name azure-cli-iot-ext
WORKDIR /home/iotedge
Expand Down
2 changes: 1 addition & 1 deletion docker/tool/windows/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $ErrorActionPreference = "Stop"
# and also make sure that
# "hosts": [ "tcp://0.0.0.0:2375" ]
# is added to your
# C:\ProgramData\Docker\config\deamon.json
# C:\ProgramData\Docker\config\daemon.json
# file

# Make sure firewall allows comminication via TCP 2375
Expand Down

0 comments on commit 2fc7b1e

Please sign in to comment.