Your Site Title

docker

Dockerfile

FROM amd64/python:3.10.14

WORKDIR /app

ENV VIRTUAL_ENV = /env
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources
RUN apt-get -y update
RUN apt-get install ffmpeg libsm6 libxext6  -y

RUN rm -f /etc/pip.conf

RUN echo "[global]" > /etc/pip.conf
RUN echo "index-url = https://pypi.mirrors.ustc.edu.cn/simple" >> /etc/pip.conf

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 9977

CMD ["python", "start.py"]

编译镜像

docker build --platform linux/amd64 -t stt .

运行

docker run -d --name stt -p 9977:9977 9ec4b290ddd9

接入

<!-- docker run -t -i <image-name-or-container-id> /bin/bash -->
docker exec -i -t <container-id> /bin/bash

docker exec -it defects /bin/sh

挂载目录

// 单目录挂载
docker run -it -v /宿主机目录:/容器目录 镜像名
// 多目录挂载
docker run -it -v /宿主机目录:/容器目录 -v /宿主机目录2:/容器目录2 镜像名
// 只读挂载
docker run -it -v  /宿主机目录:/容器目录:ro 镜像名

导出镜像

docker save -o [OUTPUT_FILE].tar [IMAGE]
docker save -o my_image.tar my_image:latest

导入镜像

docker load -i [INPUT_FILE].tar
docker load -i my_image.tar

###

docker inspect 53e1180ecb97

问题

1. OpenBLAS blas_thread_init: pthread_create failed for thread 1 of 16: Operation not permitted
docker run --security-opt seccomp:unconfined -d -p 9977:9977 --name stt 018bca116663

docker-compose-basic version: “3”

services: mariadb: container_name: mariadb image: mariadb:latest ports: - “3306:3306” environment: MYSQL_ROOT_PASSWORD: hbzxt.123 TZ: Asia/Shanghai volumes: - /home/hbzxt/./services/data/mariadb/:/var/lib/mysql - /home/hbzxt/sql:/sql - /home/hbzxt/./services/conf/mariadb.cnf:/etc/mysql/mariadb.cnf - /home/hbzxt/./services/sql/init:/docker-entrypoint-initdb.d/ networks: - hbzxt_cloud restart: on-failure privileged: true

redis: container_name: redis image: redis:latest ports: - “6379:6379” volumes: - /home/hbzxt/./services/conf/redis.conf:/usr/local/etc/redis.conf networks: - hbzxt_cloud command: /usr/local/bin/redis-server /usr/local/etc/redis.conf restart: on-failure

rabbitmq: container_name: rabbitmq image: rabbitmq:management hostname: rabbitmq ports: - “5672:5672” - “15672:15672” environment: RABBITMQ_NODENAME: rabbitmq RABBITMQ_DEFAULT_USER: hbzxt RABBITMQ_DEFAULT_PASS: hbzxt.123 volumes: - /home/hbzxt/./services/data/rabbitmq/conf/rabbitmq:/etc/rabbitmq - /home/hbzxt/./services/data/rabbitmq/lib/rabbitmq:/var/lib/rabbitmq - /home/hbzxt/./services/data/rabbitmq/log/rabbitmq/:/var/log/rabbitmq networks: - hbzxt_cloud privileged: true restart: on-failure

elasticsearch: image: elasticsearch:7.17.6 container_name: elasticsearch environment: cluster.name: elasticsearch discovery.type: single-node http.cors.enabled: “true” http.cors.allow-origin: “*” http.cors.allow-headers: X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization http.cors.allow-credentials: “true” ES_JAVA_OPTS: “-Xms512m -Xmx512m” TZ: Asia/Shanghai volumes: - /home/hbzxt/./services/data/elasticsearch/plugins:/usr/share/elasticsearch/plugins - /home/hbzxt/./services/data/elasticsearch/data:/usr/share/elasticsearch/data networks: - hbzxt_cloud ports: - 9200:9200 - 9300:9300 restart: on-failure

logstash: image: logstash:7.17.6 container_name: logstash environment: TZ: Asia/Shanghai volumes: - /home/hbzxt/./services/conf/logstash.conf:/usr/share/logstash/pipeline/logstash.conf networks: - hbzxt_cloud depends_on: - elasticsearch links: - elasticsearch:es ports: - 9600:9600 - 5044:5044 restart: on-failure

kibana: image: kibana:7.17.6 container_name: kibana links: - elasticsearch:es depends_on: - elasticsearch environment: elasticsearch.hosts: “http://es:9200” TZ: Asia/Shanghai networks: - hbzxt_cloud ports: - 5601:5601 restart: on-failure

minio: image: minio/minio:latest container_name: minio environment: MINIO_ROOT_USER: “admin” MINIO_ROOT_PASSWORD: “hbzxt.123” volumes: - /home/hbzxt/./services/data/minio:/data networks: - hbzxt_cloud ports: - 9001:9000 privileged: true command: server /data restart: on-failure

nginx: image: nginx:latest container_name: nginx volumes: - /home/hbzxt/./services/conf/nginx.conf:/etc/nginx/nginx.conf - /home/hbzxt/./services/data/nginx/logs:/etc/nginx/logs - /home/hbzxt/./services/data/nginx/html:/usr/share/nginx/html networks: - default ports: - 80:80 privileged: true restart: on-failure

portainer: image: portainer/portainer:latest container_name: portainer volumes: - /home/hbzxt/./services/data/portainer:/data - /var/run/docker.sock:/var/run/docker.sock networks: - default ports: - 9000:9000 restart: on-failure

networks: hbzxt_cloud: driver: bridge ipam: driver: default config: - subnet: 10.103.0.1/16[root@localhost services]#

Reference