Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker安装Nginx、MongoDB、Redis #40

Open
Zijue opened this issue Aug 6, 2021 · 0 comments
Open

Docker安装Nginx、MongoDB、Redis #40

Zijue opened this issue Aug 6, 2021 · 0 comments
Labels

Comments

@Zijue
Copy link
Owner

Zijue commented Aug 6, 2021

安装Redis

  • 拉取镜像
docker pull redis:6.2
  • 启动容器
docker run -v $PWD/data/:/data/ --name redis-6.2 -p 6379:6379 -d redis:6.2 redis-server --appendonly yes
  • 用用户自己设置的配置文件启动
docker run -v $PWD/conf/:/usr/local/etc/redis/ -v $PWD/data/:/data/ --name redis-6.2 -p 6379:6379 -d redis:6.2 redis-server /usr/local/etc/redis/redis.conf --appendonly yes

安装Nginx

  • 拉取镜像
docker pull nginx:1.21
  • 启动容器
docker run -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/conf/conf.d/default.conf:/etc/nginx/conf.d/default.conf --name nginx-1.21 -d -p 80:80 nginx:1.21
  • 配置nginx.conf,让docker反向代理Mac宿主机
    location / {
        # 反向代理到宿主机上的服务
        proxy_pass http://docker.for.mac.host.internal:8000;
    }

安装MongoDB

  • 拉取镜像
docker pull mongo:4.4
  • 启动容器
docker run -v $PWD/data:/data/db --name mongo-4.4 -d -p 27017:27017 mongo:4.4
  • 使用用户自己设置的配置文件启动
docker run -v $PWD/data:/data/db -v $PWD/conf:/etc/mongo --name mongo-4.4 -d -p 27017:27017 mongo:4.4 --config /etc/mongo/mongod.conf
@Zijue Zijue added the docker label Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant