标签: docker 相关的文章有 11 篇

Docker 容器的健康检查

健康检查 (HEALTHCHECK) 指令简介

健康检查 (HEALTHCHECK) 指令告诉 Docker 如何检查容器是否仍在工作。 它能够监测类似一个服务器虽然服务进程仍在运行, 但是陷入了死循环, 不能响应新的请求的情况。

当一个容器有指定健康检查 (HEALTHCHECK) 时, 它除了普通状态之外, 还有健康状态 (health status) 。 健康状态的初始状态是正在启动 (starting) , 一旦通过了一个健康检查, 它将变成健康 (healthy) (不管之前的状态是什么), 经过一定数量的连续失败之后, 它将变成不健康 (unhealthy) 。

阅读全文 ~

docker images filter 镜像查询过滤

找出tag为<none>
docker images -f "dangling=true"

找出tag为<none>的, 只返回image id
docker images -f "dangling=true" -q

根据repository名称和tag模糊过滤,我验证时,如果repository有/或小数点符号,通过*是无法匹配的
docker images --filter=reference='busy*:*libc'

使用beforesince根据时间查找,实际上以repository的名字作为时间分隔,
docker images --filter "before=image1"

docker images --filter "since=image3"

此外还有label, label=<key> or label=<key>=<value>
docker images --filter "label=com.example.version" , 这条我用docker image inspect <image id>,发现几个image的label都是空的,这个有待研究。

阅读全文 ~

很诡异的301跳转,记wordpress上线问题

话说本地用docker-compose搭了个wordpress的站点,设置里site url和home都是本地地址http://localhost:8300 ,然后上线的数据库数据是导出后导入进来。

用nginx反向代理wordpress的容器地址,浏览器卡住半天自动跳转到www.xxx.com:8300, 这很诡异啊,一直在怀疑是不是nginx配错了,proxy_redirect是off的。 即使重新安装nigix也无济无事。 curl -i 看看响应头确实301跳转了

Screen Shot 2019-07-22 at 01.15.02.png

阅读全文 ~

alpine based image to docker compose get error: command 'gcc' failed with exit status 1

Error like this:

Collecting misaka==2.1.1 (from -r requirements.txt (line 12))
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fa/87/b1020510a00aba1b936477e54180b143df654c565b84936b0b3e85272cf2/misaka-2.1.1.tar.gz (125kB)
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: 
        No working compiler found, or bogus compiler options passed to
        the compiler from Python's standard "distutils" module.  See
        the error messages above.  Likely, the problem is not related
        to CFFI but generic to the setup.py of any Python package that
        tries to compile C code.  (Hints: on OS/X 10.8, for errors about
        -mno-fused-madd see http://stackoverflow.com/questions/22313407/
        Otherwise, see https://wiki.python.org/moin/CompLangPython or
        the IRC channel #python on irc.freenode.net.)

        Trying to continue anyway.  If you are trying to install CFFI from
        a build done in a different context, you can ignore this warning.

    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/distutils/unixccompiler.py", line 118, in _compile
        extra_postargs)
      File "/usr/local/lib/python3.7/distutils/ccompiler.py", line 909, in spawn
        spawn(cmd, dry_run=self.dry_run)
      File "/usr/local/lib/python3.7/distutils/spawn.py", line 36, in spawn
        _spawn_posix(cmd, search_path, dry_run=dry_run)
      File "/usr/local/lib/python3.7/distutils/spawn.py", line 159, in _spawn_posix
        % (cmd, exit_status))
    distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 1

And my Dockerfile is here:

阅读全文 ~

Using mongodb service in docker-compose.yml

version: '3.1'

services:

  web:
    build: .
    restart: always
    ports:
      - 8080:80
    environment:      
      MONGODB_HOST: mongodb
      MONGODB_USER: root
      MONGODB_PWD: 123456
    depends_on:
      - mongodb

  mongodb:
    image: mongo:4.1
    restart: on-failure
    ports:
      - 27017:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: 123456
    volumes:
      - ./data/mongo:/data/db
      - ./data/mongo-entrypoint/:/docker-entrypoint-initdb.d/

阅读全文 ~

Dockerfile指定pip安装源

Dockerfile使用的python3.7作为基础镜像 FROM python:3.7,但是执行
RUN pip install --no-cache-dir -r requirements.txt
是默认走了这个源,https://files.pythonhosted.org/packages,编译用时太久。

无赖修改成国内源来加快编译速度:
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir -r requirements.txt

附国内其它源:
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

阅读全文 ~