• docker 实例设置自动重启


    yaml格式太严格了,每个冒号后面都必须带有空格
    在linux中
    ./代表当前目录,属于相对路径
    ../代表上一级目录,属于相对路径
    /代表根目录,/开头的文件都是绝对路径
    ./configure的意思是执行当前目录下面的configure文件
    configure一般都有可执行的权限,如果没有的话,用./configure是不能执行的,但是可以这样执行:
    sh ./configure

    设置开机启动

    systemctl enable docker

    shutdown -r now
    reboot
    重新启动

    systemctl status docker 查看是否启动状态

    --restart=always

    使用一下命令对镜像从起:

    docker restart <CONTAINER ID>

    每次docker服务重启后容器也自动重启:
    docker run --restart=always
    如果已经启动了则可以使用如下命令:
    docker update --restart=always <CONTAINER ID>


    [root@bogon mvc]# systemctl enable docker
    Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

    vi /etc/systemd/system/docker-webmvc.service

    [Unit]
    Description=docker-webmvc container
    Requires=docker.service
    After=docker.service

    [Service]
    Restart=always
    ExecStart=/usr/bin/docker start reverse-proxy mvc.web.compose
    ExecStop=/usr/bin/docker stop reverse-proxy mvc.web.compose

    [Install]
    WantedBy=default.target

    systemctl enable docker-webmvc.service
    systemctl start docker-webmvc.service
    systemctl status docker-webmvc.service

    [root@bogon mvc]# vi /etc/systemd/system/docker-webmvc.service
    [root@bogon mvc]# systemctl enable docker-webmvc.service
    Created symlink from /etc/systemd/system/default.target.wants/docker-webmvc.service to /etc/systemd/system/docker-webmvc.service.

  • 相关阅读:
    erl_0012 timer:tc 测试模块函数调用运行耗时
    erl_0011 erlang 定时器相关
    erl0010
    erl0009
    erl0008
    erl0007
    erl0006
    erl0005
    开开心心过生活、踏踏实实做技术
    Android-理解Intent
  • 原文地址:https://www.cnblogs.com/OnlyDreams/p/8432109.html
Copyright © 2020-2023  润新知