Open wtsang11 opened 2 years ago
https://docs.docker.com/compose/gettingstarted/
Redis server name in docker-compose.yml is redis-server The default port of a redis server is 6379 In app/index.js, a redis client to server:
const client = redis.createClient({ host: 'redis-server', port: 6379, });
-- like: docker run
-- stop all containers started by compose docker-compose down
Generate the project: npx create-react-app
FROM node:alpine WORKDIR '/app' COPY package.json . RUN npm install COPY . . CMD ["npm", "run", "start"]
docker run -p 3000:3000 -v /app/node_modules -v $(pwd):/app
version: '3' services: web: stdin_open: true environment: - CHOKIDAR_USEPOLLING=true build: context: . dockerfile: Dockerfile.dev ports: - '3000:3000' volumes: - /app/node_modules - .:/app
docker exec -it
-- create a second service just for test
version: '3' services: web: stdin_open: true environment: - CHOKIDAR_USEPOLLING=true build: context: . dockerfile: Dockerfile.dev ports: - '3000:3000' volumes: - /app/node_modules - .:/app tests: stdin_open: true build: context: . dockerfile: Dockerfile.dev volumes: - /app/node_modules - .:/app command: ['npm', 'run', 'test']
-- docker attach to the test container
docker attach
-- Dockerfile: two stages
FROM node:alpine as builder WORKDIR '/app' COPY package.json . RUN npm install COPY . . RUN npm run build FROM nginx COPY --from=builder /app/build /usr/share/nginx/html
-- Running the image
docker run -p 8080:80
http://localhost/TechNotes/wp-admin/post.php?post=1451&action=edit
VSC: http://localhost/lab/python/utilities/study_codes/opencodes.php?f=/Users/wtsang/Lab/docker/stephen_docker/
Running a gatsby site in docker
https://typeofnan.dev/how-to-serve-a-gatsby-app-with-nginx-in-docker/ -- why running nginx daemon off https://stackoverflow.com/questions/25970711/what-is-the-difference-between-nginx-daemon-on-off-option -- nginx directives http://nginx.org/en/docs/switches.html
-- shutdown all containers docker kill $(docker ps -q)
Running a CRM in docker
-- running a crm container using a local mysql https://hub.docker.com/r/spantree/sugarcrm
Running lemp stack in docker
https://github.com/stevenliebregt/docker-compose-lemp-stack