parent
4b1c22ac3f
commit
176b64c793
@ -0,0 +1,3 @@ |
|||||||
|
# ASYD_DOCKER |
||||||
|
|
||||||
|
Git Repository für die Beispiele und Übungen des Docker-Teils von ASYD im FS 2023. |
||||||
@ -0,0 +1,37 @@ |
|||||||
|
# Creates a simple .Net console application, writing second-tick counts to the terminal |
||||||
|
# build with: docker build -t REP/IMAGE_NAME:TAG . |
||||||
|
# run with: docker run --rm -it IMAGE_NAME <count_to> |
||||||
|
# list intermediate imgs: docker images --filter label=stage=builder |
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder |
||||||
|
LABEL stage=builder |
||||||
|
|
||||||
|
WORKDIR /app |
||||||
|
# Copy everything from src-directory on host to workdir in image |
||||||
|
COPY src . |
||||||
|
# Build and publish a release to directory "out" (build implicitly restores NuGet packages) |
||||||
|
RUN dotnet publish -c Release -o out |
||||||
|
|
||||||
|
# uncomment for testing the build-env image |
||||||
|
# CMD ["dotnet", "bin/Release/net7.0/DotnetDocker-01.dll"] |
||||||
|
|
||||||
|
# Build runtime image |
||||||
|
# FROM mcr.microsoft.com/dotnet/aspnet:7.0 |
||||||
|
FROM mcr.microsoft.com/dotnet/runtime:7.0 |
||||||
|
# create user in the image |
||||||
|
RUN groupadd -r mygroup && useradd --no-log-init --create-home --shell /bin/bash -r -g mygroup myuser |
||||||
|
# change user |
||||||
|
USER myuser |
||||||
|
# make app-dir (WORKDIR cmd would create a dir owned by root -> permission denied!) |
||||||
|
RUN mkdir /home/myuser/app |
||||||
|
# set build- and run-time working directory |
||||||
|
WORKDIR /home/myuser/app |
||||||
|
COPY --chown=myuser:mygroup --from=builder /app/out . |
||||||
|
# Opt-out of the diagnostic pipeline. This allows the container to run as read-only. |
||||||
|
ENV COMPlus_EnableDiagnostics=0 |
||||||
|
# |
||||||
|
# CMD ["dotnet", "ASYD_Demo.dll"] |
||||||
|
ENTRYPOINT ["dotnet", "ASYD_Demo.dll"] |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,5 @@ |
|||||||
|
#!/bin/bash |
||||||
|
docker build -t kaohslu/01-demo-img . |
||||||
|
docker login |
||||||
|
docker image push kaohslu/01-demo-img |
||||||
|
echo "to run type: 'docker run --rm kaohslu/01-demo-img'" |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<OutputType>Exe</OutputType> |
||||||
|
<TargetFramework>net7.0</TargetFramework> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
</Project> |
||||||
@ -0,0 +1,39 @@ |
|||||||
|
using System; |
||||||
|
using System.Threading; |
||||||
|
|
||||||
|
namespace ASYD_Demo { |
||||||
|
internal class Program { |
||||||
|
static void Main( string[] args ) { |
||||||
|
|
||||||
|
if( args.Length >= 1 && args[0] == "--help" ) { |
||||||
|
PrintUsageAndExit(); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
int a = args.Length >= 1 ? Convert.ToInt32( args[0] ) : -1; |
||||||
|
int b = args.Length >= 2 ? Convert.ToInt32( args[1] ) : -1; |
||||||
|
if( a > b ) { (a, b) = (b, a); } // swap so that a < b |
||||||
|
|
||||||
|
int counter = a >= 0 ? a : 1; |
||||||
|
int to = b >= 0 ? b : int.MaxValue; |
||||||
|
|
||||||
|
Console.WriteLine( $"Counting from {counter} to {( to == int.MaxValue ? "2^32" : to )}" ); |
||||||
|
|
||||||
|
while( counter <= to ) { |
||||||
|
Console.WriteLine( $"Counter: {counter++}" ); |
||||||
|
if( counter <= to ) |
||||||
|
Thread.Sleep( 1000 ); |
||||||
|
} |
||||||
|
} // end Main() |
||||||
|
|
||||||
|
public static void PrintUsageAndExit( int err = 0 ) { |
||||||
|
Console.WriteLine( System.AppDomain.CurrentDomain.FriendlyName + " [[from] to]" ); |
||||||
|
Console.WriteLine( " Counts in 1-second intervals . " + |
||||||
|
"If specified, counts from \"from\" to \"to\" and exists, otherwise from 0 to 2^32." ); |
||||||
|
System.Environment.Exit( err ); |
||||||
|
|
||||||
|
} // end Usage() |
||||||
|
|
||||||
|
} // end Program |
||||||
|
} // end namespace |
||||||
|
|
||||||
@ -0,0 +1,13 @@ |
|||||||
|
# on host, create named container |
||||||
|
```docker run -it --name 123deb debian``` |
||||||
|
# in container, create file in /tmp |
||||||
|
```echo "hallo ASYD" > /tmp/123.txt``` |
||||||
|
# ... and exit from container |
||||||
|
```exit``` |
||||||
|
|
||||||
|
# find the file by name starting in /var/lib/docker/ |
||||||
|
```sudo find /var/lib/docker/ -name 123.txt``` |
||||||
|
# print the file contents |
||||||
|
```sudo cat $(sudo find /var/lib/docker/ -name 123.txt)``` |
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,34 @@ |
|||||||
|
|
||||||
|
# on host, first create a directory /user/home/data |
||||||
|
|
||||||
|
# on host, create a container with a host container in /mydata |
||||||
|
```docker run --rm -it -v /home/pi/data/:/mydata debian``` |
||||||
|
|
||||||
|
# in container, change directory to volume |
||||||
|
```cd /mydata``` |
||||||
|
|
||||||
|
# create the greeting |
||||||
|
```echo "hi" > greetings.txt``` |
||||||
|
# show created file |
||||||
|
```ls -l``` |
||||||
|
# output content of created file to console |
||||||
|
```cat greetings.txt``` |
||||||
|
# exit from container |
||||||
|
```exit``` |
||||||
|
|
||||||
|
|
||||||
|
# again on the host, create another container with a named container in /stillmydata |
||||||
|
```cd /home/pi/data/``` |
||||||
|
# show greetings-file in volume |
||||||
|
```cat greetings.txt``` |
||||||
|
|
||||||
|
# need to change permissions before writing to file |
||||||
|
```sudo chmod o+w greeting.txt``` |
||||||
|
```echo " bye" >> greetings.txt``` |
||||||
|
# exit from container |
||||||
|
```cat greetings.txt``` |
||||||
|
|
||||||
|
# create a new container with a host container in /mydata |
||||||
|
```docker run --rm -it -v /home/pi/data/:/stillmydata debian``` |
||||||
|
# show greetings-file in volume |
||||||
|
```cat /stillmydata/greetings.txt``` |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
# on host, create a container with a named container in /mydata |
||||||
|
```docker run --rm -it -v myvolume:/mydata debian``` |
||||||
|
|
||||||
|
# in container, change directory to volume |
||||||
|
```cd /mydata``` |
||||||
|
|
||||||
|
# create the greeting |
||||||
|
```echo "hi from $(hostname)" > greetings.txt``` |
||||||
|
# show created file |
||||||
|
```ls -l``` |
||||||
|
# output content of created file to console |
||||||
|
```cat greetings.txt``` |
||||||
|
# exit from container |
||||||
|
```exit``` |
||||||
|
|
||||||
|
|
||||||
|
# again on host, create another container with a named container in /stillmydata |
||||||
|
```docker run --rm -it -v myvolume:/stillmydata debian``` |
||||||
|
# show greetings-file in volume |
||||||
|
```cat /stillmydata/greetings.txt``` |
||||||
|
# exit from container |
||||||
|
```exit``` |
||||||
|
|
||||||
@ -0,0 +1,19 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# get the container name from the current working directory |
||||||
|
CNT_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
echo "starting the nginx-webserver in a container named $IMGAE_NAME" |
||||||
|
docker run -it --rm -d -p 8080:80 --name $CNT_NAME nginx |
||||||
|
|
||||||
|
# tell user what to do :) |
||||||
|
echo "okay. now fire up browser and type 'http://$(hostname).simple.eee.intern:8080/' into address bar." |
||||||
|
echo "you should see the nginx welcome page." |
||||||
|
echo |
||||||
|
read -n 1 -p "press any key to copy our web-page to to container." |
||||||
|
docker cp index.html $CNT_NAME:/usr/share/nginx/html/ |
||||||
|
echo "okay, done" |
||||||
|
echo "now reload the page in your browser. you should see our web-page." |
||||||
|
echo |
||||||
|
read -n 1 -p "when done, press any key to stop (and remove) the webserver container." |
||||||
|
docker stop $CNT_NAME |
||||||
|
echo "sweet. bye!" |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
<html> |
||||||
|
<head> <title>Hello ASYD!</title> </head> |
||||||
|
<body> <h1>This is a Heading</h1> |
||||||
|
This is some text. Don't you think Docker rocks? <p> |
||||||
|
Anyways, you have just copied the file index.html from your host-computer (i.e., your Raspi) into a running container. Splendid! |
||||||
|
</body> |
||||||
|
</html> |
||||||
|
|
||||||
@ -0,0 +1,11 @@ |
|||||||
|
|
||||||
|
Creates an Image with a static web-page using docker CLI commands |
||||||
|
(not using a Dockerfile) |
||||||
|
|
||||||
|
- starts a container from the latest nginx image |
||||||
|
- copies a static webpage to it using docker cp |
||||||
|
- creates an image from the container using docker commit |
||||||
|
- starts the newly created image |
||||||
|
- cleans up on keypress after telling the user how to view the webpage |
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,40 @@ |
|||||||
|
#!/bin/bash |
||||||
|
|
||||||
|
# use the base of the current working directory as the new image name (e.g., "webimg:v1") |
||||||
|
IMAGE_NAME=$(basename $(pwd)):v1 |
||||||
|
|
||||||
|
# creates an image "myweb:v1" by commiting a container. |
||||||
|
# start with "./build.sh" in current directory |
||||||
|
|
||||||
|
# create a random container name and use throuout this scrip |
||||||
|
CNTR=$(date | md5sum | head -c 10) |
||||||
|
|
||||||
|
echo "working with container name '$CNTR'" |
||||||
|
|
||||||
|
if [ "$(docker ps -q -f name=$CNTR)" ]; then echo "container '$CNTR' exists, exiting"; exit 1; fi |
||||||
|
|
||||||
|
# create nginx-container named web |
||||||
|
docker run -it --rm -d -p 8080:80 --name $CNTR nginx |
||||||
|
|
||||||
|
# copy static webpage into container |
||||||
|
docker cp index.html $CNTR:/usr/share/nginx/html/ |
||||||
|
|
||||||
|
# commit running container to image |
||||||
|
docker commit $CNTR $IMAGE_NAME |
||||||
|
|
||||||
|
# stop container (which will also delete the container because of --rm ) |
||||||
|
docker stop $CNTR |
||||||
|
|
||||||
|
# start new container from image myweb:v1 and expose port 80 to 8080 on host |
||||||
|
docker run -it --rm -d -p 8080:80 --name $CNTR $IMAGE_NAME |
||||||
|
|
||||||
|
# tell user what to do :) |
||||||
|
echo "fire up browser and type 'http://$(hostname).simple.eee.intern:8080/' into address bar" |
||||||
|
echo "you should see our webpage" |
||||||
|
echo |
||||||
|
read -n 1 -p "when done, press any key to stop (and remove) the webserver container." |
||||||
|
echo |
||||||
|
echo "stopping container $CNTR and cleaning up, hang on...." |
||||||
|
docker stop $CNTR |
||||||
|
|
||||||
|
echo "done. bye then" |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
<html> |
||||||
|
<head> <title>Hello ASYD!</title> </head> |
||||||
|
<body> <h1>This is a Heading</h1> |
||||||
|
This is some text. |
||||||
|
</body> |
||||||
|
</html> |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
FROM gcc |
||||||
|
WORKDIR /myapp |
||||||
|
COPY hello-world.c . |
||||||
|
RUN gcc -o hello-world hello-world.c |
||||||
|
CMD ["/myapp/hello-world"] |
||||||
|
|
||||||
@ -0,0 +1,23 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# get the image name from the current working directory |
||||||
|
IMG_NAME=$(basename $(pwd)) |
||||||
|
# create a random container name and use throuout this scrip |
||||||
|
CNTR=$(date | md5sum | head -c 10) |
||||||
|
|
||||||
|
docker build -t $IMG_NAME . |
||||||
|
echo "starting the container with: 'docker run --rm $IMG_NAME'" |
||||||
|
|
||||||
|
echo "creating a container with: 'docker create --name $CTNR $IMG_NAME'" |
||||||
|
docker create --name $CNTR $IMG_NAME |
||||||
|
|
||||||
|
echo "copying /myapp from container to host: 'docker cp $CNTR:/myapp/hello-world .'" |
||||||
|
docker cp $CNTR:/myapp/hello-world . |
||||||
|
|
||||||
|
echo "removing the container with: 'docker rm $CTNR'" |
||||||
|
docker rm $CNTR |
||||||
|
|
||||||
|
echo "starting hello-world from the host: './hello-world'" |
||||||
|
./hello-world |
||||||
|
|
||||||
|
|
||||||
|
# echo "to start a bash in the container, run: 'docker run --rm -it $IMG_NAME bash'" |
||||||
Binary file not shown.
@ -0,0 +1,6 @@ |
|||||||
|
#include <stdio.h> |
||||||
|
int main() { |
||||||
|
printf("Hello World from within my very own Docker Container :)\n"); |
||||||
|
return 0; |
||||||
|
} // end main()
|
||||||
|
|
||||||
@ -0,0 +1,4 @@ |
|||||||
|
# file Dockerfile |
||||||
|
FROM debian |
||||||
|
COPY greetings.txt /tmp |
||||||
|
|
||||||
@ -0,0 +1,17 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# get the container name from the current working directory |
||||||
|
IMG_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
docker build -t $IMG_NAME . |
||||||
|
|
||||||
|
echo "In the image do:" |
||||||
|
echo " cd /tmp" |
||||||
|
echo " ls -l" |
||||||
|
echo " cat greetings.txt" |
||||||
|
|
||||||
|
|
||||||
|
docker run --rm -it $IMG_NAME |
||||||
|
|
||||||
|
# can also string together commands to execute at container-start |
||||||
|
# docker run --rm -it $IMG_NAME sh -c "cat /tmp/greetings.txt; ls -l /tmp/greetings.txt" |
||||||
|
|
||||||
@ -0,0 +1 @@ |
|||||||
|
hi there! |
||||||
@ -0,0 +1,3 @@ |
|||||||
|
# file Dockerfile |
||||||
|
FROM debian |
||||||
|
RUN echo "hallo ASYD" > /tmp/greetings.txt |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# get the container name from the current working directory |
||||||
|
IMG_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
docker build -t $IMG_NAME . |
||||||
|
|
||||||
|
echo "In the image do:" |
||||||
|
echo " cd /tmp" |
||||||
|
echo " ls -l" |
||||||
|
echo " cat greetings.txt" |
||||||
|
|
||||||
|
|
||||||
|
docker run --rm -it $IMG_NAME |
||||||
|
|
||||||
|
# can also string together commands to execute at container-start |
||||||
|
# docker run --rm -it $IMG_NAME sh -c "cat /tmp/greetings.txt; ls -l /tmp/greetings.txt" |
||||||
|
|
||||||
@ -0,0 +1,3 @@ |
|||||||
|
# file Dockerfile |
||||||
|
FROM debian |
||||||
|
RUN echo "hallo ASYD" > /tmp/greetings.txt && echo "bye, bye" > /tmp/bye.txt |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# get the container name from the current working directory |
||||||
|
IMG_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
docker build -t $IMG_NAME . |
||||||
|
|
||||||
|
echo "In the image do:" |
||||||
|
echo " cd /tmp" |
||||||
|
echo " ls -l" |
||||||
|
echo " cat greetings.txt" |
||||||
|
|
||||||
|
|
||||||
|
docker run --rm -it $IMG_NAME |
||||||
|
|
||||||
|
# can also string together commands to execute at container-start |
||||||
|
# docker run --rm -it $IMG_NAME sh -c "cat /tmp/greetings.txt; ls -l /tmp/greetings.txt" |
||||||
|
|
||||||
@ -0,0 +1,3 @@ |
|||||||
|
# file Dockerfile |
||||||
|
FROM debian |
||||||
|
RUN echo "hallo ASYD" > /tmp/greetings.txt |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# get the container name from the current working directory |
||||||
|
IMG_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
docker build -t $IMG_NAME . |
||||||
|
|
||||||
|
echo "In the image do:" |
||||||
|
echo " cd /tmp" |
||||||
|
echo " ls -l" |
||||||
|
echo " cat greetings.txt" |
||||||
|
|
||||||
|
|
||||||
|
docker run --rm -it $IMG_NAME |
||||||
|
|
||||||
|
# can also string together commands to execute at container-start |
||||||
|
# docker run --rm -it $IMG_NAME sh -c "cat /tmp/greetings.txt; ls -l /tmp/greetings.txt" |
||||||
|
|
||||||
@ -0,0 +1,8 @@ |
|||||||
|
# file Dockerfile |
||||||
|
FROM debian |
||||||
|
RUN mkdir /mydata && \ |
||||||
|
echo "hi there!" > /mydata/greetings.txt && \ |
||||||
|
apt-get update && apt-get install -y nano && apt-get clean && \ |
||||||
|
rm -rf /var/lib/apt/lists/* |
||||||
|
CMD ["nano", "/mydata/greetings.txt"] |
||||||
|
|
||||||
@ -0,0 +1,7 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# get the container name from the current working directory |
||||||
|
IMG_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
docker build -t $IMG_NAME . |
||||||
|
|
||||||
|
docker run --rm -it $IMG_NAME |
||||||
@ -0,0 +1 @@ |
|||||||
|
hi there! |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
# file Dockerfile |
||||||
|
FROM debian |
||||||
|
WORKDIR /mydata |
||||||
|
RUN echo "hi there!" > greetings.txt |
||||||
|
# the created file is in /mydata/greetings.txt |
||||||
|
|
||||||
@ -0,0 +1,20 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# get the image name from the current working directory |
||||||
|
IMG_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
# create a random container name and use throuout this scrip |
||||||
|
CNTR=$(date | md5sum | head -c 10) |
||||||
|
|
||||||
|
|
||||||
|
docker build -t $IMG_NAME . |
||||||
|
|
||||||
|
# create container without running it |
||||||
|
docker create --name $CNTR $IMG_NAME |
||||||
|
# copy the file to working directory of the host |
||||||
|
docker cp $CNTR:/mydata/greetings.txt . |
||||||
|
# remove container again |
||||||
|
docker rm $CNTR |
||||||
|
|
||||||
|
# now list new file |
||||||
|
ls -l greetings.txt |
||||||
|
|
||||||
@ -0,0 +1,17 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# get the container name from the current working directory |
||||||
|
IMG_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
docker build -t $IMG_NAME . |
||||||
|
|
||||||
|
echo "In the image do:" |
||||||
|
echo " cd /tmp" |
||||||
|
echo " ls -l" |
||||||
|
echo " cat greetings.txt" |
||||||
|
|
||||||
|
|
||||||
|
docker run --rm -it $IMG_NAME |
||||||
|
|
||||||
|
# can also string together commands to execute at container-start |
||||||
|
# docker run --rm -it $IMG_NAME sh -c "cat /tmp/greetings.txt; ls -l /tmp/greetings.txt" |
||||||
|
|
||||||
@ -0,0 +1,4 @@ |
|||||||
|
# file Dockerfile |
||||||
|
FROM debian |
||||||
|
COPY greetings.txt /tmp |
||||||
|
|
||||||
@ -0,0 +1 @@ |
|||||||
|
hi there! |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
# Datei Dockerfile |
||||||
|
FROM debian |
||||||
|
WORKDIR /app |
||||||
|
COPY hello-world . |
||||||
|
CMD ["/app/hello-world"] |
||||||
|
|
||||||
Binary file not shown.
@ -0,0 +1,11 @@ |
|||||||
|
|
||||||
|
Creates an Image with a static web-page using docker CLI commands |
||||||
|
(not using a Dockerfile) |
||||||
|
|
||||||
|
- starts a container from the latest nginx image |
||||||
|
- copies a static webpage to it using docker cp |
||||||
|
- creates an image from the container using docker commit |
||||||
|
- starts the newly created image |
||||||
|
- cleans up on keypress after telling the user how to view the webpage |
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,34 @@ |
|||||||
|
#!/bin/bash |
||||||
|
|
||||||
|
# creates an image "myweb:v1" by commiting a container. |
||||||
|
# start with "./build.sh" in current directory |
||||||
|
|
||||||
|
# create a random container name and use throuout this scrip |
||||||
|
CNTR=$(date | md5sum | head -c 10) |
||||||
|
|
||||||
|
echo "working with container name '$CNTR'" |
||||||
|
|
||||||
|
if [ "$(docker ps -q -f name=$CNTR)" ]; then echo "container '$CNTR' exists, exiting"; exit 1; fi |
||||||
|
|
||||||
|
# create nginx-container named web |
||||||
|
docker run -it --rm -d -p 8080:80 --name $CNTR nginx |
||||||
|
|
||||||
|
# copy static webpage into container |
||||||
|
docker cp index.html $CNTR:/usr/share/nginx/html/ |
||||||
|
|
||||||
|
# commit running container to image |
||||||
|
docker commit $CNTR myweb:v1 |
||||||
|
|
||||||
|
# stop container (which will also delete the container because of --rm ) |
||||||
|
docker stop $CNTR |
||||||
|
|
||||||
|
# start new container from image myweb:v1 and expose port 80 to 8080 on host |
||||||
|
docker run -it --rm -d -p 8080:80 --name $CNTR myweb:v1 |
||||||
|
|
||||||
|
# tell user what to do :) |
||||||
|
echo "fire up browser and type 'http://$(hostname).simple.eee.intern:8080/' into address bar" |
||||||
|
read -n 1 -p "when done, press any key to stop (and remove) the webserver container." |
||||||
|
echo "stopping container $CNTR and cleaning up, hang on...." |
||||||
|
docker stop $CNTR |
||||||
|
|
||||||
|
echo "done. bye then :)" |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
<html> |
||||||
|
<head> <title>Hello ASYD!</title> </head> |
||||||
|
<body> <h1>This is a Heading</h1> |
||||||
|
This is some text. |
||||||
|
</body> |
||||||
|
</html> |
||||||
@ -0,0 +1,5 @@ |
|||||||
|
# Datei Dockerfile |
||||||
|
FROM nginx |
||||||
|
COPY index.html /usr/share/nginx/html/ |
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,3 @@ |
|||||||
|
#!/bin/bash |
||||||
|
docker build -t myweb:v2 . |
||||||
|
|
||||||
@ -0,0 +1,6 @@ |
|||||||
|
<html> |
||||||
|
<head> <title>Hello ASYD!</title> </head> |
||||||
|
<body> <h1>This is a Heading</h1> |
||||||
|
This is some text. |
||||||
|
</body> |
||||||
|
</html> |
||||||
@ -0,0 +1,5 @@ |
|||||||
|
# Datei Dockerfile |
||||||
|
FROM debian |
||||||
|
RUN apt-get update |
||||||
|
RUN apt-get install -y nano |
||||||
|
|
||||||
@ -0,0 +1,3 @@ |
|||||||
|
#!/bin/bash |
||||||
|
docker build -t nanodeb:v1 . |
||||||
|
|
||||||
@ -0,0 +1,7 @@ |
|||||||
|
# Datei Dockerfile |
||||||
|
FROM debian |
||||||
|
RUN apt-get update && \ |
||||||
|
apt-get install -y nano && \ |
||||||
|
apt-get clean && \ |
||||||
|
rm -rf /var/lib/apt/lists/* |
||||||
|
|
||||||
@ -0,0 +1,3 @@ |
|||||||
|
#!/bin/bash |
||||||
|
docker build -t nanodeb:v2 . |
||||||
|
|
||||||
@ -0,0 +1,8 @@ |
|||||||
|
# Datei Dockerfile |
||||||
|
FROM debian |
||||||
|
RUN apt-get update && \ |
||||||
|
apt-get install -y nano && \ |
||||||
|
apt-get clean && \ |
||||||
|
rm -rf /var/lib/apt/lists/* |
||||||
|
CMD ["nano", "/greeting.txt"] |
||||||
|
|
||||||
@ -0,0 +1,3 @@ |
|||||||
|
#!/bin/bash |
||||||
|
docker build -t nanodeb:v3 . |
||||||
|
|
||||||
@ -0,0 +1,9 @@ |
|||||||
|
# Datei Dockerfile |
||||||
|
FROM debian |
||||||
|
RUN apt-get update && \ |
||||||
|
apt-get install -y nano && \ |
||||||
|
apt-get clean && \ |
||||||
|
rm -rf /var/lib/apt/lists/* |
||||||
|
ENTRYPOINT ["nano"] |
||||||
|
CMD ["/greeting.txt"] |
||||||
|
|
||||||
@ -0,0 +1,3 @@ |
|||||||
|
#!/bin/bash |
||||||
|
docker build -t nanodeb:v4 . |
||||||
|
|
||||||
@ -0,0 +1,10 @@ |
|||||||
|
# Datei Dockerfile |
||||||
|
FROM debian |
||||||
|
RUN apt-get update && \ |
||||||
|
apt-get install -y nano && \ |
||||||
|
apt-get clean && \ |
||||||
|
rm -rf /var/lib/apt/lists/* |
||||||
|
WORKDIR /app |
||||||
|
ENTRYPOINT ["nano"] |
||||||
|
CMD ["/greeting.txt"] |
||||||
|
|
||||||
@ -0,0 +1,3 @@ |
|||||||
|
#!/bin/bash |
||||||
|
docker build -t nanodeb:v5 . |
||||||
|
|
||||||
@ -0,0 +1,4 @@ |
|||||||
|
FROM scratch |
||||||
|
COPY hello-world2 / |
||||||
|
CMD ["/hello-world2"] |
||||||
|
|
||||||
@ -0,0 +1,5 @@ |
|||||||
|
#!/bin/bash |
||||||
|
docker build -t myscratch . |
||||||
|
|
||||||
|
echo "running with: 'docker run --rm myscratch'" |
||||||
|
docker run --rm myscratch |
||||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,15 @@ |
|||||||
|
#!/bin/bash |
||||||
|
docker run -it --rm -d -p 8080:80 --name webcp nginx |
||||||
|
|
||||||
|
# tell user what to do :) |
||||||
|
echo "okay, fire up browser and type 'http://$(hostname).simple.eee.intern:8080/' into address bar." |
||||||
|
echo "you should see the nginx welcome page." |
||||||
|
echo |
||||||
|
read -n 1 -p "then press any key to copy our web-page to to container." |
||||||
|
docker cp index.html web:/usr/share/nginx/html/ |
||||||
|
echo "okay, done" |
||||||
|
echo "now reload the page in your browser. you should see our web-page." |
||||||
|
echo |
||||||
|
read -n 1 -p "when done, press any key to stop (and remove) the webserver container." |
||||||
|
docker stop webcp |
||||||
|
echo "sweet. bye" |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
<html> |
||||||
|
<head> <title>Hello ASYD!</title> </head> |
||||||
|
<body> <h1>This is a Heading</h1> |
||||||
|
This is some text. |
||||||
|
</body> |
||||||
|
</html> |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
# file Dockerfile |
||||||
|
FROM debian |
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y netcat |
||||||
|
WORKDIR /app |
||||||
|
COPY start_cmd.sh . |
||||||
|
RUN mkfifo /app/netcat_fifo |
||||||
|
RUN echo "hi there" |
||||||
|
CMD ["/app/start_cmd.sh"] |
||||||
|
|
||||||
@ -0,0 +1,6 @@ |
|||||||
|
#!/bin/bash |
||||||
|
IMAGE_NAME=$(basename $(pwd)) |
||||||
|
docker build -t $IMAGE_NAME . |
||||||
|
echo |
||||||
|
echo "run with: 'docker run --rm -p4321:1234 $IMAGE_NAME'" |
||||||
|
echo "on host start: 'nc host.example.com 4321'" |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
# file docker-compose.yml |
||||||
|
version: '3' |
||||||
|
|
||||||
|
services: |
||||||
|
nc-server: |
||||||
|
# image: netcat_server |
||||||
|
build: . |
||||||
|
restart: unless-stopped |
||||||
|
ports: |
||||||
|
- "4321:1234" |
||||||
@ -0,0 +1,3 @@ |
|||||||
|
#!/bin/bash |
||||||
|
cat /app/netcat_fifo | /bin/sh -i 2>&1 | nc -l 1234 > /app/netcat_fifo |
||||||
|
|
||||||
@ -0,0 +1,11 @@ |
|||||||
|
FROM golang:1.13 AS build |
||||||
|
|
||||||
|
WORKDIR /compose/hello-docker |
||||||
|
COPY main.go main.go |
||||||
|
RUN CGO_ENABLED=0 go build -o backend main.go |
||||||
|
|
||||||
|
FROM scratch |
||||||
|
COPY --from=build /compose/hello-docker/backend /usr/local/bin/backend |
||||||
|
CMD ["/usr/local/bin/backend"] |
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,30 @@ |
|||||||
|
package main |
||||||
|
|
||||||
|
import ( |
||||||
|
"fmt" |
||||||
|
"log" |
||||||
|
"net/http" |
||||||
|
) |
||||||
|
|
||||||
|
func handler(w http.ResponseWriter, r *http.Request) { |
||||||
|
fmt.Println(r.URL.RawQuery) |
||||||
|
fmt.Fprintf(w, ` |
||||||
|
## . |
||||||
|
## ## ## == |
||||||
|
## ## ## ## ## === |
||||||
|
/"""""""""""""""""\___/ === |
||||||
|
{ / ===- |
||||||
|
\______ O __/ |
||||||
|
\ \ __/ |
||||||
|
\____\_______/ |
||||||
|
|
||||||
|
|
||||||
|
Hello from Docker! |
||||||
|
|
||||||
|
`) |
||||||
|
} |
||||||
|
|
||||||
|
func main() { |
||||||
|
http.HandleFunc("/", handler) |
||||||
|
log.Fatal(http.ListenAndServe(":80", nil)) |
||||||
|
} |
||||||
@ -0,0 +1,9 @@ |
|||||||
|
services: |
||||||
|
frontend: |
||||||
|
build: frontend |
||||||
|
ports: |
||||||
|
- 80:80 |
||||||
|
depends_on: |
||||||
|
- backend |
||||||
|
backend: |
||||||
|
build: backend |
||||||
@ -0,0 +1,4 @@ |
|||||||
|
FROM nginx:alpine |
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf |
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,6 @@ |
|||||||
|
server { |
||||||
|
listen 80; |
||||||
|
location / { |
||||||
|
proxy_pass http://backend:80; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,32 @@ |
|||||||
|
# Datei test/docker-compose.yml |
||||||
|
version: '3' |
||||||
|
|
||||||
|
services: |
||||||
|
db: |
||||||
|
image: mariadb:latest |
||||||
|
volumes: |
||||||
|
- vol-db:/var/lib/mysql |
||||||
|
environment: |
||||||
|
MYSQL_RANDOM_ROOT_PASSWORD: 1 |
||||||
|
MYSQL_DATABASE: wp |
||||||
|
MYSQL_USER: wpuser |
||||||
|
MYSQL_PASSWORD: geheim |
||||||
|
restart: unless-stopped |
||||||
|
|
||||||
|
wordpress: |
||||||
|
image: wordpress:latest |
||||||
|
volumes: |
||||||
|
- vol-www:/var/www/html/wp-content |
||||||
|
ports: |
||||||
|
- "8082:80" |
||||||
|
environment: |
||||||
|
WORDPRESS_DB_HOST: db:3306 |
||||||
|
WORDPRESS_DB_USER: wpuser |
||||||
|
WORDPRESS_DB_NAME: wp |
||||||
|
WORDPRESS_DB_PASSWORD: geheim |
||||||
|
restart: unless-stopped |
||||||
|
|
||||||
|
volumes: |
||||||
|
vol-www: |
||||||
|
vol-db: |
||||||
|
|
||||||
@ -0,0 +1,3 @@ |
|||||||
|
# file: Dockerfile |
||||||
|
FROM alpine |
||||||
|
RUN echo "hallo asyd" |
||||||
@ -0,0 +1,4 @@ |
|||||||
|
FROM alpine |
||||||
|
|
||||||
|
RUN touch /tmp/xyz.txt |
||||||
|
|
||||||
@ -0,0 +1,4 @@ |
|||||||
|
FROM alpine |
||||||
|
|
||||||
|
RUN echo "hallo asyd" > /tmp/xyz.txt |
||||||
|
|
||||||
@ -0,0 +1,24 @@ |
|||||||
|
#!/bin/bash |
||||||
|
IMAGE_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** creating an image from Dockerfile.v1 with name my_alpine" |
||||||
|
|
||||||
|
docker build . -f Dockerfile.v1 -t $IMAGE_NAME |
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "***listing all images" |
||||||
|
docker image ls |
||||||
|
|
||||||
|
read -n 1 -p "press any key to create an image with the same name from a slightly changed Dockerfile.v2" |
||||||
|
|
||||||
|
docker build . -f Dockerfile.v2 -t $IMAGE_NAME |
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** listing all images" |
||||||
|
docker image ls |
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** note the 'dangling' image named <none>:<none>" |
||||||
|
echo "*** to list only dangling images use: docker images --filter dangling=true" |
||||||
|
docker images --filter dangling=true |
||||||
@ -0,0 +1,15 @@ |
|||||||
|
FROM alpine as builder |
||||||
|
|
||||||
|
# install gcc |
||||||
|
RUN apk update && apk add gcc musl-dev |
||||||
|
|
||||||
|
WORKDIR /app |
||||||
|
COPY hello-world.c /app |
||||||
|
RUN gcc -o hello-world hello-world.c |
||||||
|
|
||||||
|
FROM alpine |
||||||
|
|
||||||
|
WORKDIR /app |
||||||
|
COPY --from=builder /app/hello-world /app |
||||||
|
CMD ["/app/hello-world"] |
||||||
|
|
||||||
@ -0,0 +1,11 @@ |
|||||||
|
#!/bin/bash |
||||||
|
|
||||||
|
IMAGE_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** building image with: 'docker build . -t $IMAGE_NAME'" |
||||||
|
|
||||||
|
|
||||||
|
docker build . -t $IMAGE_NAME |
||||||
|
echo "***" |
||||||
|
echo "*** run with: 'docker run --rm $IMAGE_NAME'" |
||||||
Binary file not shown.
@ -0,0 +1,6 @@ |
|||||||
|
#include <stdio.h> |
||||||
|
int main() { |
||||||
|
printf("Hello World from within my very own Docker Container :)\n"); |
||||||
|
return 0; |
||||||
|
} // end main()
|
||||||
|
|
||||||
@ -0,0 +1,13 @@ |
|||||||
|
|
||||||
|
|
||||||
|
Start the SDK--container interactively, mounting the current directory as /app in the container |
||||||
|
$ docker run --rm -it -v $(pwd):/app mcr.microsoft.com/dotnet/sdk:5.0 |
||||||
|
|
||||||
|
Change to folder ./app which contains the ./src folder (/app/src) |
||||||
|
# cd /app |
||||||
|
|
||||||
|
Start the build using /app/src as source folder and writing to /app/out |
||||||
|
# dotnet publish -c Release -o out src |
||||||
|
|
||||||
|
That's it, exit |
||||||
|
# exit |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<OutputType>Exe</OutputType> |
||||||
|
<TargetFramework>net7.0</TargetFramework> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
</Project> |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
# file: Dockerfile |
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder |
||||||
|
|
||||||
|
WORKDIR /app |
||||||
|
# Copy everything from src-directory on host to workdir in image |
||||||
|
|
||||||
|
COPY src . |
||||||
|
# Build and publish a release to directory "out" (build implicitly restores NuGet packages) |
||||||
|
RUN dotnet publish -c Release -o out |
||||||
|
|
||||||
|
CMD ["dotnet", "/app/out/ConsoleApp1.dll"] |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
!/bin/bash |
||||||
|
IMAGE_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** buildig image with: 'docker build . -t $IMAGE_NAME'" |
||||||
|
docker build . -t $IMAGE_NAME |
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** start image with: 'docker run --rm -t $IMAGE_NAME'" |
||||||
|
docker run --rm -t $IMAGE_NAME |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<OutputType>Exe</OutputType> |
||||||
|
<TargetFramework>net7.0</TargetFramework> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
</Project> |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
# file: Dockerfile |
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder |
||||||
|
|
||||||
|
WORKDIR /app |
||||||
|
|
||||||
|
# Copy everything from src-directory on host to workdir in image |
||||||
|
COPY src . |
||||||
|
|
||||||
|
# Build and publish a release to directory "out" (build implicitly restores NuGet packages) |
||||||
|
RUN dotnet publish -c Release -o out |
||||||
|
|
||||||
|
# Build runtime image |
||||||
|
FROM mcr.microsoft.com/dotnet/runtime:7.0 |
||||||
|
|
||||||
|
# install GPIO library (don't clean, need cache :-) |
||||||
|
RUN apt-get -y update && apt-get -y install gpiod libgpiod2 libgpiod-dev |
||||||
|
|
||||||
|
# set build- and run-time working directory |
||||||
|
WORKDIR /app |
||||||
|
|
||||||
|
COPY --from=builder /app/out /app |
||||||
|
|
||||||
|
CMD ["dotnet", "/app/ConsoleApp1.dll"] |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
#!/bin/bash |
||||||
|
IMAGE_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** buildig image with: 'docker build . -t $IMAGE_NAME'" |
||||||
|
docker build . -t $IMAGE_NAME |
||||||
|
|
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** start image with: 'docker run --rm --device /dev/gpiochip0 $IMAGE_NAME'" |
||||||
|
docker run --rm $IMAGE_NAME |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<OutputType>Exe</OutputType> |
||||||
|
<TargetFramework>net7.0</TargetFramework> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
</Project> |
||||||
@ -0,0 +1,2 @@ |
|||||||
|
FROM debian |
||||||
|
RUN apt-get -y update && apt-get -y install gpiod |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
#!/bin/bash |
||||||
|
|
||||||
|
IMAGE_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** building image with: 'docker build . -t $IMAGE_NAME'" |
||||||
|
|
||||||
|
docker build . -t $IMAGE_NAME |
||||||
|
echo "***" |
||||||
|
echo "*** after starting the image, execute (within the container): 'gpioset 0 20=1' to switch on yellow LED" |
||||||
|
echo "*** starting image with: 'docker run --rm -it --device=/dev/gpiochip0 $IMAGE_NAME'" |
||||||
|
docker run --rm -it --device=/dev/gpiochip0 $IMAGE_NAME |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
#FROM debian |
||||||
|
|
||||||
|
# file: Dockerfile |
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder |
||||||
|
|
||||||
|
WORKDIR /app |
||||||
|
|
||||||
|
# Copy everything from src-directory on host to workdir in image |
||||||
|
COPY src . |
||||||
|
|
||||||
|
# Build and publish a release to directory "out" (build implicitly restores NuGet packages) |
||||||
|
RUN dotnet publish -c Release -o out |
||||||
|
|
||||||
|
# Build runtime image |
||||||
|
FROM mcr.microsoft.com/dotnet/runtime:7.0 |
||||||
|
|
||||||
|
# install GPIO library (don't clean, need cache :-) |
||||||
|
RUN apt-get -y update && apt-get -y install gpiod libgpiod2 libgpiod-dev |
||||||
|
|
||||||
|
# set build- and run-time working directory |
||||||
|
WORKDIR /app |
||||||
|
|
||||||
|
COPY --from=builder /app/out /app |
||||||
|
|
||||||
|
CMD ["dotnet", "/app/ASYD_JoystickLeds.dll"] |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
#!/bin/bash |
||||||
|
|
||||||
|
IMAGE_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** buildig image with: 'docker build . -t $IMAGE_NAME'" |
||||||
|
docker build . -t $IMAGE_NAME |
||||||
|
|
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** start image with: 'docker run --rm --device /dev/gpiochip0 $IMAGE_NAME'" |
||||||
|
docker run --rm -it --device /dev/gpiochip0 $IMAGE_NAME |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
FROM gcc as builder |
||||||
|
|
||||||
|
WORKDIR /myapp |
||||||
|
COPY hello-world.c /myapp |
||||||
|
RUN gcc -static -o hello-world hello-world.c |
||||||
|
|
||||||
|
FROM alpine |
||||||
|
|
||||||
|
WORKDIR /myapp |
||||||
|
COPY --from=builder /myapp/hello-world /myapp |
||||||
|
CMD ["/myapp/hello-world"] |
||||||
|
|
||||||
@ -0,0 +1,9 @@ |
|||||||
|
#!/bin/bash |
||||||
|
IMAGE_NAME=$(basename $(pwd)) |
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** buildig image with: 'docker build . -t $IMAGE_NAME'" |
||||||
|
docker build . -t $IMAGE_NAME |
||||||
|
|
||||||
|
echo "***" |
||||||
|
echo "*** run with: 'docker run --rm $IMAGE_NAME'" |
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue