# 构建并后台启动
$ docker compose up -d
# 将会停止UP命令启动的容器,并删除容器
$ docker compose down
镜像地址:https://hub.docker.com/_/nginx
docker-compose.yml
version: '3'
services:
web:
image: nginx:1.23.2
restart: always
hostname: nginx
container_name: nginx_123
privileged: true
ports:
- 8080:80
volumes:
#- ./conf/nginx.conf:/etc/nginx/nginx.conf
- ./logs/:/var/log/nginx/
- ./html/:/usr/share/nginx/html/
镜像地址:https://hub.docker.com/_/httpd
# docker-compose.yml
version: '3'
services:
web:
container_name: httpd
image: httpd:2.4.54
ports:
- "8081:80"
privileged: true
volumes:
#- ./conf/httpd.conf:/usr/local/apache2/conf/httpd.conf
- "./html/:/usr/local/apache2/htdocs/"
镜像地址:https://hub.docker.com/_/openjdk
version: "3"
services:
java-service:
container_name: java-web
restart: always
network_mode: "host"
image: liberica-openjdk-centos:11.0.17
volumes:
- ./web-0.1.jar:/web-0.1.jar
ports:
- "80:80"
#启动容器后执行的命令
entrypoint: java -Xms1024m -Xmx1024m -jar web-0.1.jar
可用的openjdk容器
amazoncorretto:https://hub.docker.com/_/amazoncorretto
docker pull amazoncorretto:8u352
docker pull amazoncorretto:11.0.17
docker pull amazoncorretto:17.0.5
bellsoft:https://hub.docker.com/u/bellsoft
docker pull bellsoft/liberica-openjdk-centos:8u352
docker pull bellsoft/liberica-openjdk-centos:17.0.5
docker pull bellsoft/liberica-openjdk-centos:11.0.17
eclipse-temurin:https://hub.docker.com/_/eclipse-temurin
版本标签:https://github.com/docker-library/docs/blob/master/eclipse-temurin/README.md
docker pull eclipse-temurin:8u352-b08-jdk
docker pull eclipse-temurin:11.0.17_8-jdk
docker pull eclipse-temurin:17.0.5_8-jdk
镜像地址:https://hub.docker.com/_/ubuntu
# docker-compose.yml
version: '3'
services:
web:
container_name: ubuntu
image: ubuntu:22.04
privileged: true
volumes:
- /etc/localtime:/etc/localtime
network_mode: "host"
其它操作系统
alpine:https://hub.docker.com/_/alpine
docker run -it -v /data/docker/linux:/root alpine:3.17.0 /bin/sh
debian:https://hub.docker.com/_/debian
docker run -it -p 9311:9311 -v /data/docker/linux:/root debian:11.6 /bin/sh
amazonlinux:https://hub.docker.com/_/amazonlinux
docker run -it -p 9311:9311 -v /data/docker/linux:/root amazonlinux:2.0.20221210.0 /bin/sh
oraclelinux:https://hub.docker.com/_/oraclelinux
docker run -it -p 9311:9311 -v /data/docker/linux:/root oraclelinux:9 /bin/sh
archlinux:https://hub.docker.com/_/archlinux
docker run -it -p 9311:9311 -v /data/docker/linux:/root archlinux:latest /bin/sh
photon:https://hub.docker.com/_/photon
docker run -it -p 9311:9311 -v /data/docker/linux:/root photon:4.0 /bin/sh
rockylinux:https://hub.docker.com/_/rockylinux
docker run -it -p 9311:9311 -v /data/docker/linux:/root rockylinux:9.1 /bin/sh
clearlinux:https://hub.docker.com/_/clearlinux
docker run -it -p 9311:9311 -v /data/docker/linux:/root clearlinux:latest /bin/sh
opensuse:https://hub.docker.com/r/opensuse/leap
docker run -it -p 9311:9311 -v /data/docker/linux:/root opensuse/leap:15.4 /bin/sh
fedora:https://hub.docker.com/_/fedora
docker run -it -p 9311:9311 -v /data/docker/linux:/root fedora:37 /bin/sh