IT-SDK-Docker

From wiki.samerhijazi.net
Revision as of 17:23, 24 January 2020 by Fiducia (talk | contribs) (Run)
Jump to navigation Jump to search

Source

Installation

Fedora-Source: https://docs.docker.com/install/linux/docker-ce/fedora/

$ 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-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

Work-Cycle

Mix

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
docker system prune
docker container ls
docker image ls
docker volume ls

Build

$ docker build -t $NAME_IMAGE:0.1 $LOCATION_DOCKERFILE
$ docker build -t appAngular .
$ docker build -t hijazi/sig:v3 /home/samer

Run

Abkurzungen: -d: Rund container in Background (Detached Mode), -p: port, --rm: remove container, -v: Mount a volume($LOCATION_LOCAL:$LOCATION_DOCKER).

$ docker run -d -p $ID_PORT --name $NAME_CONTAINER $NAME_IMAGE
$ docker run -d -p 80:80 --name mynginx2 nginx
$ docker run --rm -v c:/Users:/data alpine ls /data
$ winpty docker run -it ubuntu bash
$ winpty docker run --rm hello-world
$ docker exec -i -t $NAME_CONTAINER /bin/bash
$ docker start $NAME_CONTAINER  
$ docker stop $NAME_CONTAINER

Dockerfile

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

Docker-File


FROM debian:stretch-slim
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
EXPOSE 80
STOPSIGNAL SIGTERM
CMD ["nginx", "-g", "daemon off;"]