Last active
November 15, 2018 05:56
-
-
Save myclau/187f98823285891031e9387de1349879 to your computer and use it in GitHub Desktop.
library for store usually template for fast implement new docker image or local debug.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#run | |
docker run -name=xxx -p 80:80 imagename:version | |
#exec | |
docker exec -it container-name command (usually sh) | |
#remove all | |
docker stop $(docker ps -aq) | |
docker rm $(docker ps -aq) | |
#logs | |
docker logs -tf container-name | |
#compose | |
#run and in seems session | |
docker-compose up | |
#run in daemon mode (prefer) | |
docker-compose up -d | |
#stop | |
docker-compose down | |
#stop and remove volume (better when you will create volume , and you dot want to keep it ) | |
docker-compose down -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# normal | |
RUN groupadd -r groupname &&\ | |
useradd -d /home/username -r -g groupname username | |
# alpine | |
addgroup -S groupname &&\ | |
adduser --home /home/username -S -G groupname username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
appname="demo-app" | |
docker build --tag "custom-$appname" . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
nginx: | |
image: "custom-demo-app" | |
ports: | |
- "1234:80" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -o errexit | |
currentverion=$(cat tag) | |
tagname=XXX/demo-app | |
docker_repo=dockerhub.xxx.com | |
docker build -t tmpimage . | |
docker tag tmpimage ${docker_repo}/${tagname}:latest | |
docker tag tmpimage ${docker_repo}/${tagname}:${currentverion?Error: cannot find current tag version} | |
docker push ${docker_repo}/${tagname}:latest | |
docker push ${docker_repo}/${tagname}:${currentverion?Error: cannot find current tag version} | |
docker rmi tmpimage | |
docker rmi ${docker_repo}/${tagname}:${currentverion?Error: cannot find current tag version} | |
docker rmi ${docker_repo}/${tagname}:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM maven:3.6.0-jdk-8 AS MAVEN_TOOL_CHAIN | |
COPY pom.xml /tmp/pom.xml | |
COPY src /tmp/src | |
WORKDIR /tmp/ | |
RUN mvn package -e -X | |
FROM openjdk:8-jdk-alpine AS base | |
VOLUME /tmp | |
COPY --from=MAVEN_TOOL_CHAIN /tmp/target/*.war app.war | |
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.war"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment