Last active
March 1, 2021 01:17
-
-
Save veevidify/e4a527f646e40d5b2a0f8aff988dc8cd to your computer and use it in GitHub Desktop.
Docker scripts
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
# images | |
docker images -f dangling=true -q --no-trunc | xargs docker rmi | |
# containers | |
docker container ls -a -f status=exited -q --no-trunc | grep "search_container" | grep -v 'CONTAINER' | awk '{print $1}' | xargs docker container rm | |
# volumes | |
docker volume ls -qf dangling=true | xargs -r docker volume rm | |
# network | |
docker network ls | grep "search_network" | awk '/ / {print $1}' | xargs docker network rm |
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/bash | |
args="$@" | |
docker-compose run --name some_custom_name service-name $args |
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: '3' | |
services: | |
react: | |
container_name: react_react | |
build: | |
context: . | |
dockerfile: react.Dockerfile | |
volumes: | |
- ${PATH_PREFIX}:/app | |
command: ["yarn", "start"] | |
ports: | |
- ${APP_PORT}:3000 | |
environment: | |
- CHOKIDAR_USEPOLLING=true | |
cli: | |
container_name: react_cli | |
build: | |
context: . | |
dockerfile: react.Dockerfile | |
volumes: | |
- ${PATH_PREFIX}:/app | |
entrypoint: ["yarn"] |
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
# pull official base image | |
FROM node:10.16-alpine | |
# set working directory | |
WORKDIR /app | |
# add `/app/node_modules/.bin` to $PATH | |
ENV PATH /app/node_modules/.bin:$PATH | |
# install app dependencies | |
RUN npm install -g yarn | |
# add app | |
COPY . ./ | |
RUN yarn install --silent | |
RUN yarn add react-scripts@3.0 | |
# start app | |
CMD ["yarn", "start"] |
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/bash | |
docker run --network some_network --rm -it -v /path/to/work/dir:/app -w /app image-name:1.0-alpine /bin/sh -c "echo 'your command here'" | |
# node | |
docker run --rm -it -v "/your/work/dir:/app" -w "/app" -u 1000 node:12-alpine yarn install | |
docker run --rm -it -v "/your/work/dir:/app" -u 1000 -p 3000:3000 -w "/app" -e CHOKIDAR_USEPOLLING=true --env-file /your/work/dir/.env node:12-alpine yarn start | |
# php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment