zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    逻辑代码题:五个学生参加计算机比赛
    逻辑代码题:如果昨天是明天,那今天就是周五了
    面试题:二叉树的遍历
    面试题:判断链表是否存在环
    面试题:将字符串中的中英文分开显示
    N皇后
    2017<java技术>预备作业2计科陈刚
    transition+transform合并效果案例
    transition CSS3动画属性之过渡
    Less 编译的几种方式
  • 原文地址:https://www.cnblogs.com/OnlyDreams/p/8432109.html
Copyright © 2011-2022 走看看