Cleanup Docker files (#7328)

* update docker read me to point to new repo
* remove unused files
This commit is contained in:
Travis Plunk 2018-07-23 15:19:58 -07:00 committed by GitHub
parent 5c11f09706
commit 80d2af8934
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 3 additions and 702 deletions

View file

@ -1,165 +1,9 @@
# Docker
These DockerFiles enable running PowerShell in a container for each Linux distribution we support.
This requires an up-to-date version of Docker, such as 1.12.
It also expects you to be able to run Docker without `sudo`.
Please follow [Docker's official instructions][install] to install `docker` correctly.
[install]: https://docs.docker.com/engine/installation/
## Release
The release containers derive from the official distribution image,
such as `centos:7`, then install dependencies,
and finally install the PowerShell package.
These containers live at [hub.docker.com/r/microsoft/powershell][docker-release].
At about 440 megabytes, they are decently minimal,
with their size being the sum of the base image (200 megabytes)
plus the uncompressed package (120 megabytes),
and about 120 megabytes of .NET Core and bootstrapping dependencies.
[docker-release]: https://hub.docker.com/r/microsoft/powershell/
Docker file to build the Docker images for PowerShell Core have been moved to [PowerShell/PowerShell-Docker](https://github.com/PowerShell/PowerShell-Docker)
## Community
The docker files in the community folder were contributed by the community and are not yet officially supported.
The docker files in the `community` folder were contributed by the community and are not yet officially supported.
## Examples
To run PowerShell from using a container:
```sh
$ docker run -it microsoft/powershell
Unable to find image 'microsoft/powershell:latest' locally
latest: Pulling from microsoft/powershell
cad964aed91d: Already exists
3a80a22fea63: Already exists
50de990d7957: Already exists
61e032b8f2cb: Already exists
9f03ce1741bf: Already exists
adf6ad28fa0e: Pull complete
10db13a8ca02: Pull complete
75bdb54ff5ae: Pull complete
Digest: sha256:92c79c5fcdaf3027626643aef556344b8b4cbdaccf8443f543303319949c7f3a
Status: Downloaded newer image for microsoft/powershell:latest
PowerShell
Copyright (c) Microsoft Corporation. All rights reserved.
PS /> Write-Host "Hello, World!"
Hello, World!
```
## Building the images
The images are built with the [`docker image build`](https://docs.docker.com/engine/reference/commandline/image_build/) command.
### Example
```sh
PS /powershell/docker> cd ./release/ubuntu16.04/
PS /powershell/docker/release/ubuntu16.04> docker image build -t ps-ubuntu.16.04 .
Sending build context to Docker daemon 3.072 kB
Step 1/12 : FROM ubuntu:xenial
---> 7b9b13f7b9c0
Step 2/12 : LABEL maintainer "PowerShell Team <powershellteam@hotmail.com>"
---> Using cache
---> c6515b7d596f
Step 3/12 : LABEL readme.md "https://github.com/PowerShell/PowerShell/blob/master/docker/README.md"
---> Using cache
---> 721306ae4490
Step 4/12 : LABEL description "This Dockerfile will install the latest release of PS."
---> Using cache
---> 80c06f5481d2
Step 5/12 : RUN apt-get update && apt-get install -y --no-install-recommends apt-utils ca-certificates curl apt-transport-https locales && rm -rf /var/lib/apt/lists/*
---> Using cache
---> 2d08e2300fc9
Step 6/12 : ENV LANG en_US.UTF-8
---> Using cache
---> 6dfc363111c0
Step 7/12 : ENV LC_ALL $LANG
---> Using cache
---> b7ef2cd3a7ed
Step 8/12 : RUN locale-gen $LANG && update-locale
---> Using cache
---> e75306ddf3e0
Step 9/12 : RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
---> Using cache
---> f476b7be22a2
Step 10/12 : RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | tee /etc/apt/sources.list.d/microsoft.list
---> Using cache
---> 909ca8e33a3b
Step 11/12 : RUN apt-get update && apt-get install -y --no-install-recommends powershell
---> Using cache
---> f32b54204619
Step 12/12 : ENTRYPOINT powershell
---> Using cache
---> ee667ad86a7b
Successfully built ee667ad86a7b
```
### Run the docker image you built
```sh
PS /powershell/docker/release/ubuntu16.04> docker run -it ps-ubuntu.16.04 powershell -c '$psversiontable'
Name Value
---- -----
PSVersion 6.0.0-beta
PSEdition Core
BuildVersion 3.0.0.0
CLRVersion
GitCommitId v6.0.0-beta.2
OS Linux 4.9.27-moby #1 SMP Thu May 11 04:01:18 ...
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
## NanoServer-Insider Release Notes
Please be sure to use a build from the Windows Insider program, either [Windows Server Insider](https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewserver) or the [Windows 10 Insider](https://insider.windows.com/GettingStarted),
as your Container host before trying to pull this image. Otherwise, pulling this image will **fail**.
Read more about the changes coming to Nano Server in future releases of Windows Server Insider [here](https://docs.microsoft.com/windows-server/get-started/nano-in-semi-annual-channel).
### This is pre-release software
Windows Server Insider Preview builds may be substantially modified before they are commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Some product features and functionality may require additional hardware or software. These builds are for testing purposes only. Microsoft is not obligated to provide any support services for this preview software.
For more information see [Using Insider Container Images](https://github.com/Microsoft/Virtualization-Documentation/blob/live/virtualization/windowscontainers/quick-start/Using-Insider-Container-Images.md)
and [Build and run an application with or without .NET Core 2.0 or PowerShell Core 6](https://github.com/Microsoft/Virtualization-Documentation/blob/live/virtualization/windowscontainers/quick-start/Nano-RS3-.NET-Core-and-PS.md).
### Known Issues
#### PowerShell Get only works with CurrentUser Scope
Due to [known issues with the nano-server-insider](https://github.com/Microsoft/Virtualization-Documentation/blob/live/virtualization/windowscontainers/quick-start/Insider-Known-Issues.md#build-16237),
you must specify `-Scope CurrentUser` when using `Install-Module`. Example:
```PowerShell
Install-Module <ModuleName> -Scope CurrentUser
```
#### Docker run requires full path
> **Note:** this is fixed in `10.0.16257.1000` of the NanoServer-Insider build. The powershell version of this should be released soon.
Due to [an issue with the container not picking up the path](https://github.com/Microsoft/Virtualization-Documentation/blob/live/virtualization/windowscontainers/quick-start/Insider-Known-Issues.md#build-16237), you must specify the path
when running a command on the command line. For example, you would expect to be able to run:
```PowerShell
PS > docker run -it microsoft/nanoserver-insider-powershell powershell -c '$psversiontable'
```
but, in `nanoserver-insider-powershell` you must run:
```PowerShell
PS > docker run -it microsoft/nanoserver-insider-powershell 'C:\program files\powershell\powershell' -c '$psversiontable'
```
We plan to move these to [PowerShell/PowerShell-Docker](https://github.com/PowerShell/PowerShell-Docker) once we have a separate channel for publishing community supported images.

View file

@ -1,48 +0,0 @@
# Docker image file that describes an Centos7 image with PowerShell installed from Microsoft YUM Repo
ARG FromTag=7
FROM centos:${FromTag}
ARG POWERSHELL_VERSION=6.0.2
ARG IMAGE_NAME=microsoft/powershell:centos7
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" \
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
description="This Dockerfile will install the latest release of PS." \
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" \
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell" \
org.label-schema.name="powershell" \
org.label-schema.vendor="PowerShell" \
org.label-schema.version=${POWERSHELL_VERSION} \
org.label-schema.schema-version="1.0" \
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" \
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" \
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" \
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
# TODO: addd LABEL org.label-schema.vcs-ref=${VCS_REF}
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG
# Install dependencies and clean up
RUN yum install -y \
curl \
&& yum clean all
# Download and configure Microsoft Repository config file
RUN set -o pipefail \
&& curl https://packages.microsoft.com/config/rhel/7/prod.repo | tee /etc/yum.repos.d/microsoft.repo
# Install latest powershell from Microsoft YUM Repo
RUN yum install -y \
powershell-${POWERSHELL_VERSION} \
&& yum clean all
# Use PowerShell as the default shell
# Use array to avoid Docker prepending /bin/sh -c
CMD [ "pwsh" ]

View file

@ -1,47 +0,0 @@
# Docker image file that describes an fedora 25 image with PowerShell installed from Microsoft YUM Repo
ARG FromTag=26
FROM fedora:${FromTag}
ARG POWERSHELL_VERSION=6.0.2
ARG IMAGE_NAME=microsoft/powershell:fedora26
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" \
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
description="This Dockerfile will install the latest release of PS." \
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" \
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell" \
org.label-schema.name="powershell" \
org.label-schema.vendor="PowerShell" \
org.label-schema.version=${POWERSHELL_VERSION} \
org.label-schema.schema-version="1.0" \
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" \
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" \
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" \
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
# TODO: addd LABEL org.label-schema.vcs-ref=${VCS_REF}
# Install dependencies and clean up
RUN dnf install -y \
curl \
glibc-locale-source \
&& dnf upgrade-minimal -y --security \
&& dnf clean all
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG
# Download and configure Microsoft Repository config file
RUN set -o pipefail \
&& curl https://packages.microsoft.com/config/rhel/7/prod.repo | tee /etc/yum.repos.d/microsoft.repo
# Install latest powershell from Microsoft YUM Repo
RUN dnf install -y powershell-${POWERSHELL_VERSION} \
&& dnf clean all
# Use array to avoid Docker prepending /bin/sh -c
CMD [ "pwsh" ]

View file

@ -1,48 +0,0 @@
# Docker image file that describes an fedora 27 image with PowerShell installed from Microsoft YUM Repo
ARG FromTag=27
FROM fedora:${FromTag}
ARG POWERSHELL_VERSION=6.0.2
ARG IMAGE_NAME=microsoft/powershell:fedora27
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" \
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
description="This Dockerfile will install the latest release of PS." \
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" \
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell" \
org.label-schema.name="powershell" \
org.label-schema.vendor="PowerShell" \
org.label-schema.version=${POWERSHELL_VERSION} \
org.label-schema.schema-version="1.0" \
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" \
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" \
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" \
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
# TODO: addd LABEL org.label-schema.vcs-ref=${VCS_REF}
# Install dependencies and clean up
RUN dnf install -y \
curl \
glibc-locale-source \
compat-openssl10 \
&& dnf upgrade-minimal -y --security \
&& dnf clean all
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG
# Download and configure Microsoft Repository config file
RUN set -o pipefail \
&& curl https://packages.microsoft.com/config/rhel/7/prod.repo | tee /etc/yum.repos.d/microsoft.repo
# Install latest powershell from Microsoft YUM Repo
RUN dnf install -y powershell-${POWERSHELL_VERSION} \
&& dnf clean all
# Use array to avoid Docker prepending /bin/sh -c
CMD [ "pwsh" ]

View file

@ -1,57 +0,0 @@
# escape=`
# Args used by from statements must be defined here:
ARG NanoServerVersion=1709
ARG WindowsServerCoreVersion=latest
ARG WindowsServerCoreRepo=microsoft/windowsservercore
ARG NanoServerRepo=microsoft/nanoserver
# Use server core as an installer container to extract PowerShell,
# As this is a multi-stage build, this stage will eventually be thrown away
FROM ${WindowsServerCoreRepo}:$WindowsServerCoreVersion AS installer-env
# Arguments for installing powershell, must be defined in the container they are used
ARG PS_VERSION=6.0.2
ENV PS_DOWNLOAD_URL https://github.com/PowerShell/PowerShell/releases/download/v$PS_VERSION/PowerShell-$PS_VERSION-win-x64.zip
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN if (!($env:PS_VERSION -match '^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$' )) {throw ('PS_Version ({0}) must match the regex "^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$"' -f $env:PS_VERSION)}
ADD $PS_DOWNLOAD_URL /powershell.zip
RUN Expand-Archive powershell.zip -DestinationPath \PowerShell
# Install PowerShell into NanoServer
FROM ${NanoServerRepo}:$NanoServerVersion
ARG VCS_REF="none"
ARG PS_VERSION=6.0.2
ARG IMAGE_NAME=microsoft/powershell
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" `
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" `
description="This Dockerfile will install the latest release of PS." `
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" `
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" `
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell" `
org.label-schema.name="powershell" `
org.label-schema.vcs-ref=${VCS_REF} `
org.label-schema.vendor="PowerShell" `
org.label-schema.version=${PS_VERSION} `
org.label-schema.schema-version="1.0" `
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" `
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" `
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" `
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
# Copy Powershell Core from the installer containter
ENV ProgramFiles C:\Program Files
COPY --from=installer-env ["\\PowerShell\\", "$ProgramFiles\\PowerShell"]
# Persist %PSCORE% ENV variable for user convenience
ENV PSCORE="$ProgramFiles\PowerShell\pwsh.exe"
# Set the path
RUN setx PATH "%PATH%;%ProgramFiles%\PowerShell"
CMD ["pwsh.exe"]

View file

@ -1,58 +0,0 @@
# Docker image file that describes an OpenSUSE 42.2 image with PowerShell installed from PowerShell Release
ARG FromTag=42.2
FROM opensuse:${FromTag}
ARG POWERSHELL_VERSION=6.0.2
ARG POWERSHELL_PACKAGE=powershell-6.0.2-linux-x64.tar.gz
ARG IMAGE_NAME=microsoft/powershell:opensuse42.2
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" \
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
description="This Dockerfile will install the latest release of PS." \
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" \
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell" \
org.label-schema.name="powershell" \
org.label-schema.vendor="PowerShell" \
org.label-schema.version=${POWERSHELL_VERSION} \
org.label-schema.schema-version="1.0" \
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" \
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" \
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" \
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
# TODO: addd LABEL org.label-schema.vcs-ref=${VCS_REF}
# Update, Install packages to generate localedef and CURL which is used by RPM
# add the Microsoft key as trusted to install packgages using RPM
# Install PowerShell then clean up
RUN zypper --non-interactive update --skip-interactive \
&& zypper --non-interactive install \
glibc-locale \
glibc-i18ndata \
tar \
curl \
libunwind \
libicu \
openssl \
&& zypper --non-interactive clean --all
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN localedef --charmap=UTF-8 --inputfile=en_US $LANG
# Get the InstallTarballPackage.sh script
ADD https://raw.githubusercontent.com/PowerShell/PowerShell/master/docker/InstallTarballPackage.sh /InstallTarballPackage.sh
# Add execution permission
RUN chmod +x /InstallTarballPackage.sh
# Install powershell from tarball package
RUN /InstallTarballPackage.sh $POWERSHELL_VERSION $POWERSHELL_PACKAGE
# Remove the script
RUN rm -f /InstallTarballPackage.sh
CMD [ "pwsh" ]

View file

@ -1,59 +0,0 @@
# Docker image file that describes an Ubuntu14.04 image with PowerShell installed from Microsoft APT Repo
ARG FromTag=14.04
FROM ubuntu:${FromTag}
ARG POWERSHELL_VERSION=6.0.2
ARG POWERSHELL_VERSION_POSTFIX=-1.ubuntu.14.04
ARG IMAGE_NAME=microsoft/powershell:ubuntu14.04
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" \
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
description="This Dockerfile will install the latest release of PS." \
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" \
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell" \
org.label-schema.name="powershell" \
org.label-schema.vendor="PowerShell" \
org.label-schema.version=${POWERSHELL_VERSION} \
org.label-schema.schema-version="1.0" \
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" \
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" \
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" \
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
# TODO: addd LABEL org.label-schema.vcs-ref=${VCS_REF}
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN locale-gen $LANG && update-locale
# Install dependencies and clean up
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
curl \
apt-transport-https \
&& apt-get dist-upgrade -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Import the public repository GPG keys for Microsoft
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
# Register the Microsoft Ubuntu 14.04 repository
RUN set -o pipefail \
&& curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list | tee /etc/apt/sources.list.d/microsoft.list
# Install powershell from Microsoft Repo
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
powershell=${POWERSHELL_VERSION}${POWERSHELL_VERSION_POSTFIX} \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Use PowerShell as the default shell
# Use array to avoid Docker prepending /bin/sh -c
CMD [ "pwsh" ]

View file

@ -1,60 +0,0 @@
# Docker image file that describes an Ubuntu16.04 image with PowerShell installed from Microsoft APT Repo
ARG FromTag=16.04
FROM ubuntu:${FromTag}
ARG POWERSHELL_VERSION=6.0.2
ARG POWERSHELL_VERSION_POSTFIX=-1.ubuntu.16.04
ARG IMAGE_NAME=microsoft/powershell:ubuntu16.04
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" \
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
description="This Dockerfile will install the latest release of PS." \
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" \
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell" \
org.label-schema.name="powershell" \
org.label-schema.vendor="PowerShell" \
org.label-schema.version=${POWERSHELL_VERSION} \
org.label-schema.schema-version="1.0" \
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" \
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" \
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" \
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
# TODO: addd LABEL org.label-schema.vcs-ref=${VCS_REF}
# Install dependencies and clean up
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
curl \
apt-transport-https \
locales \
&& apt-get dist-upgrade -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN locale-gen $LANG && update-locale
# Import the public repository GPG keys for Microsoft
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
# Register the Microsoft Ubuntu 16.04 repository
RUN set -o pipefail \
&& curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | tee /etc/apt/sources.list.d/microsoft.list
# Install powershell from Microsoft Repo
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
powershell=${POWERSHELL_VERSION}${POWERSHELL_VERSION_POSTFIX} \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Use PowerShell as the default shell
# Use array to avoid Docker prepending /bin/sh -c
CMD [ "pwsh" ]

View file

@ -1,61 +0,0 @@
# escape=`
FROM microsoft/windowsservercore:latest
ARG POWERSHELL_MSI=https://github.com/PowerShell/PowerShell/releases/download/v6.0.2/PowerShell-6.0.2-win-x64.msi
ARG POWERSHELL_VERSION=6.0.2
ARG IMAGE_NAME=microsoft/powershell:windowsservercore
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" `
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" `
description="This Dockerfile will install the latest release of PS." `
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" `
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" `
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell" `
org.label-schema.name="powershell" `
org.label-schema.vendor="PowerShell" `
org.label-schema.version=${POWERSHELL_VERSION} `
org.label-schema.schema-version="1.0" `
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" `
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" `
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" `
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
# TODO: addd LABEL org.label-schema.vcs-ref=${VCS_REF}
RUN setx /M PATH "%ProgramFiles%\PowerShell\latest;%PATH%"
# Setup PowerShell - Log-to > C:\Docker.log
SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"]
ADD $POWERSHELL_MSI /PowerShell-win-x64.msi
# Install PowerShell package and clean up
RUN $ErrorActionPreference='Stop'; `
$ConfirmPreference='None'; `
$VerbosePreference='Continue'; `
Start-Transcript -path C:\Dockerfile.log -append -IncludeInvocationHeader ; `
$PSVersionTable | Write-Output ; `
$VerInfo = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' ; `
('FullBuildString: '+$VerInfo.BuildLabEx) | Write-Output ; `
('OperatingSystem: '+$VerInfo.ProductName+' '+$VerInfo.EditionId+' '+$VerInfo.InstallationType) | Write-Output ; `
[System.IO.FileInfo]$MsiFile = Get-Item -Path ./PowerShell-win-x64.msi ; `
Start-Process -FilePath msiexec.exe -ArgumentList '-qn','-i c:\PowerShell-win-x64.msi', `
'-log c:\PowerShell-win-x64.msi.log','-norestart' -wait ; `
$log=get-content -Path C:\PowerShell-win-x64.msi.log -Last 10 ; `
if ($log -match 'Installation success or error status: 0') { `
Remove-Item -Path $MsiFile ; `
$psexe=Get-Item -Path $Env:ProgramFiles\PowerShell\*\pwsh.exe ; `
New-Item -Type SymbolicLink -Path $Env:ProgramFiles\PowerShell\ -Name latest -Value $psexe.DirectoryName `
} else { throw 'Installation failed! See c:\PowerShell-win-x64.msi.log' } ;
# Verify New pwsh.exe runs
SHELL ["C:\\Program Files\\PowerShell\\latest\\pwsh.exe", "-command"]
RUN Start-Transcript -path C:\Dockerfile.log -append -IncludeInvocationHeader ; `
$ErrorActionPreference='Stop'; `
Write-Output $PSVersionTable ; `
If (-not($PSVersionTable.PSEdition -Match 'Core')) { `
Throw [String]$('['+$PSVersionTable.PSEdition+'] is not [Core]!') ; `
} ;
# Persist %PSCORE% ENV variable for user convenience
ENV PSCORE='"C:\Program Files\PowerShell\latest\pwsh.exe"'
CMD ["pwsh.exe"]

View file

@ -1,105 +0,0 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Import-module -Name "$PSScriptRoot\containerTestCommon.psm1" -Force
$script:linuxContainerTests = Get-LinuxContainer
$script:windowsContainerTests = Get-WindowsContainer
$script:skipLinux = Test-SkipLinux
$script:skipWindows = Test-SkipWindows
Describe "Build Linux Containers" -Tags 'Build', 'Linux' {
BeforeAll {
Set-RepoName 'pscontainertest'
}
it "$(Get-RepoName):<Name> builds from '<path>'" -TestCases $script:linuxContainerTests -Skip:$script:skipLinux {
param(
[Parameter(Mandatory=$true)]
[string]
$name,
[Parameter(Mandatory=$true)]
[string]
$path
)
{ Invoke-Docker -Command build -Params '--pull', '--quiet', '-t', "$(Get-RepoName):${Name}", $path -SuppressHostOutput} | should not throw
}
}
Describe "Build Windows Containers" -Tags 'Build', 'Windows' {
BeforeAll {
Set-RepoName 'pscontainertest'
}
it "$(Get-RepoName):<Name> builds from '<path>'" -TestCases $script:windowsContainerTests -skip:$script:skipWindows {
param(
[Parameter(Mandatory=$true)]
[string]
$name,
[Parameter(Mandatory=$true)]
[string]
$path
)
{ Invoke-Docker -Command build -Params @(
'--pull'
'--quiet'
'-t'
"$(Get-RepoName):${Name}"
$path
) -SuppressHostOutput} | should not throw
}
}
Describe "Linux Containers run PowerShell" -Tags 'Behavior', 'Linux' {
BeforeAll{
$testContext = Get-TestContext -type Linux
}
AfterAll{
# prune unused volumes
$null=Invoke-Docker -Command 'volume', 'prune' -Params '--force' -SuppressHostOutput
}
BeforeEach {
Remove-Item $testContext.resolvedXmlPath -ErrorAction SilentlyContinue
Remove-Item $testContext.resolvedLogPath -ErrorAction SilentlyContinue
}
it "Get PSVersion table from $(Get-RepoName):<Name>" -TestCases $script:linuxContainerTests -Skip:$script:skipLinux {
param(
[Parameter(Mandatory=$true)]
[string]
$name,
[Parameter(Mandatory=$true)]
[string]
$path
)
Get-ContainerPowerShellVersion -TestContext $testContext -Name $Name -RepoName (Get-RepoName) | should be '6.0.2'
}
}
Describe "Windows Containers run PowerShell" -Tags 'Behavior', 'Windows' {
BeforeAll{
$testContext = Get-TestContext -type Windows
}
BeforeEach {
Remove-Item $testContext.resolvedXmlPath -ErrorAction SilentlyContinue
Remove-Item $testContext.resolvedLogPath -ErrorAction SilentlyContinue
}
it "Get PSVersion table from $(Get-RepoName):<Name>" -TestCases $script:windowsContainerTests -skip:$script:skipWindows {
param(
[Parameter(Mandatory=$true)]
[string]
$name,
[Parameter(Mandatory=$true)]
[string]
$path
)
Get-ContainerPowerShellVersion -TestContext $testContext -Name $Name -RepoName (Get-RepoName) | should be '6.0.2'
}
}