Difference between revisions of "IT-SDK-Docker"
Jump to navigation
Jump to search
Samerhijazi (talk | contribs) (→LC-run) |
Samerhijazi (talk | contribs) (→LC-run) |
||
| Line 116: | Line 116: | ||
* '''--name''': Name of container. | * '''--name''': Name of container. | ||
<pre class="code"> | <pre class="code"> | ||
| − | $ docker run --name $STRING --rm -d -p $PORT:$PORT -v $LOCATION:$LOCATION $NAME_IMAGE | + | $ docker run --name $STRING --rm -it -d -p $PORT:$PORT -v $LOCATION:$LOCATION $NAME_IMAGE |
| − | $ docker run --name linux --rm -d -p 80:80 -v C:/Users:/home alpine | + | $ docker run --name linux --rm -it -d -p 80:80 -v C:/Users:/home alpine |
... | ... | ||
$ winpty docker run -it ubuntu bash | $ winpty docker run -it ubuntu bash | ||
Revision as of 10:15, 8 January 2021
Source
- https://cloud.google.com/container-registry/docs/pulling-cached-images#docker-ui
- >>>> https://github.com/Philip-Scott/docker-workspace
- VS-Code & Containers: https://code.visualstudio.com/docs/remote/containers
- CheatSheet: https://www.docker.com/sites/default/files/d8/2019-09/docker-cheat-sheet.pdf
- Source: https://docs.docker.com/v17.09/engine/reference/builder/
- Link: http://docs.projectatomic.io/container-best-practices/#_abstract
- Link: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
- Website-CMD: (https://docs.docker.com/engine/reference/commandline/)
- Website-TUT: (https://docs.docker.com/engine/tutorials/usingdocker/)
- Portainer: (http://portainer.io/index.html) stammt aus UI-for-Docker (https://github.com/kevana/ui-for-docker)
- Docker & Kubernetes: https://www.middlewareinventory.com/blog/deploy-docker-image-to-kubernetes/
- Docker & Kubernetes: https://www.linode.com/docs/kubernetes/deploy-container-image-to-kubernetes/
Definitions
- Docker Compose is a tool for defining and running multi-container Docker applications
Installation
docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
fedora
- Fedora-Source: https://docs.docker.com/install/linux/docker-ce/fedora/
- https://fedoramagazine.org/docker-and-fedora-32/
$ sudo dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine $ sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo $ sudo dnf install docker-ce docker-ce-cli containerd.io .. $ sudo groupadd docker $ sudo usermod -aG docker $USER .. $ sudo systemctl start docker $ sudo systemctl enable docker
ubuntu
Ubuntu-Source: https://docs.docker.com/install/linux/docker-ce/ubuntu/
$ sudo apt-get remove docker docker-engine docker.io containerd runc $ sudo apt-get update $ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" $ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io .. $ sudo groupadd docker $ sudo usermod -aG docker $USER
Life-Cycle
Fast
docker build -t zgv/app-angular . docker run --rm -d -p 90:80/tcp zgv/app-angular --name app-angular docker exec -it app-angular bash curl localhost:80
LC-mix
docker ps -a -q docker stop $(docker ps -a -q) docker rm $(docker ps -a -q)
docker-machine ip docker pull hijazi/sig docker pusch hijazi/sig .. docker images -a docker rmi hijazi/sig:v1# remove .. docker run -d -P hijazi/sig:v1 /bin/bash docker run -d -p 80:5000 hijazi/sig:v1 /bin/bash docker run -d -p 9000:9000 portainer/portainer -H tcp://<REMOTE_HOST>:<REMOTE_PORT> docker run -t -i hijazi/sig:v1 /bin/bash .. docker ps –a # Liste all Containers docker rm CONTIANER_NAME # Remove contianer decker rename CONTAINER_ID CONTIANER_NEW_NAME .. docker build -t hijazi/sig:v3 /home/samer docker tag 9d6e50edcaad hijazi/sig:dev docker commit -m "Massage" -a "Creator" 9d6e50edcaad hijazi/sig:v2
LC-Clean
docker system prune # Remove all Unused container docker system prune --all # Remove all Unused container and all unused images docker system prune --volumes # Remove all Unused container and all unused volumes docker container ls docker image ls docker volume ls
LC-build
$ docker build -t $NAME_IMAGE:0.1 $LOCATION_DOCKERFILE $ docker build -t local/app . $ docker build -t local/app:$(date +%Y%m%d.%H%M%S) .
LC-run
Abkurzungen:
- -d: Detached Mode, run container in Background.
- -p: Port: -p 80:80.
- -v: Mount a volume: $LOCATION_in_LOCAL:$LOCATION_in_DOCKER
- -it: i: Keep STDIN open; t: Allocate a pseudo-TTY.
- --rm: Remove container after exit.
- --name: Name of container.
$ docker run --name $STRING --rm -it -d -p $PORT:$PORT -v $LOCATION:$LOCATION $NAME_IMAGE $ docker run --name linux --rm -it -d -p 80:80 -v C:/Users:/home alpine ... $ winpty docker run -it ubuntu bash $ winpty docker run --rm hello-world
$ docker start $NAME_CONTAINER $ docker stop $NAME_CONTAINER
LC-exec
# In Linux-OS $ docker exec -it $NAME_CONTAINER bash $ docker exec -it $NAME_CONTAINER sh ... # In Windows-OS $ winpty docker exec -it $NAME_CONTAINER bash $ winpty docker exec -it $NAME_CONTAINER sh
LC-commit
$ docker commit $CONTAINER_ID $NEW_IMAGE_NAME
Dockerfile
Dockerfile-Definition
FROM Sets the base image for subsequent MAINTAINER Sets the author field of the generated images RUN Execute commands in a new layer on top of the current image and commit the results CMD Allowed only once (if many then last one takes effect) LABEL Adds metadata to an image EXPOSE Informs container runtime that the container listens on the specified network ports at runtime ENV Sets an environment variable ADD Copy new files, directories, or remote file URLs from >> into the filesystem of the container COPY (this) Copy new files or directories >> into the filesystem of the container ENTRYPOINT Allows you to configure a container that will run as an executable VOLUME Creates a mount point and marks it as holding externally mounted volumes from native host or other containers USER Sets the username or UID to use when running the image WORKDIR Sets the working directory for any RUN, CMD, ENTRYPOINT, COPY, and ADD commands ARG Defines a variable that users can pass at build-time to the builder using --build-arg ONBUILD Adds an instruction to be executed later, when the image is used as the base for another build STOPSIGNAL Sets the system call signal that will be sent to the container to exit
Dockerfile-Template
FROM debian:stretch-slim USER root LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" WORKDIR /app COPY nginx-repo.crt /etc/ssl/nginx/ RUN apt-get update && apt-get upgrade -y RUN chmod 777 /etc/nginx/conf.d/default.conf /etc/nginx/nginx.conf /var/cache/nginx/* EXPOSE 80 STOPSIGNAL SIGTERM CMD ["nginx", "-g", "daemon off;"] USER 1001
Docker-Images
Image: Jenkins
export WORKSPACE=/workspace ... sudo docker run --detach \ --hostname jenkins.box-blue \ --publish 49001:8080 \ --name jenkins \ --restart always \ --volume $WORKSPACE/jenkins:/var/jenkins_home:z \ --tty jenkins/jenkins
Image: GitLab
export WORKSPACE=/workspace ... sudo docker run --detach \ --hostname gitlab.box-blue \ --publish 443:443 \ --publish 80:80 \ --publish 22:22 \ --name gitlab \ --restart always \ --volume $WORKSPACE/gitlab/config:/etc/gitlab \ --volume $WORKSPACE/gitlab/logs:/var/log/gitlab \ --volume $WORKSPACE/gitlab/data:/var/opt/gitlab \ gitlab/gitlab-ce:latest ... sudo docker exec -it gitlab /bin/bash
Image: Postgres
sudo docker run -d \ -p 5432:5432 \ -e POSTGRES_PASSWORD=admin \ -e POSTGRES_USER=admin \ -e POSTGRES_DB=trymore_eu \ --name postgres \ postgres