• docker基本使用


    docker日志

    /var/log/upstart/docker.log 

    docker两个基本配置文件地址

    /etc/init/docker.conf

     1 description "Docker daemon"
     2 
     3 start on (filesystem and net-device-up IFACE!=lo)
     4 stop on runlevel [!2345]
     5 
     6 limit nofile 524288 1048576
     7 
     8 # Having non-zero limits causes performance problems due to accounting overhead
     9 # in the kernel. We recommend using cgroups to do container-local accounting.
    10 limit nproc unlimited unlimited
    11 
    12 respawn
    13 
    14 kill timeout 20
    15 
    16 pre-start script
    17     # see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
    18     if grep -v '^#' /etc/fstab | grep -q cgroup 
    19         || [ ! -e /proc/cgroups ] 
    20         || [ ! -d /sys/fs/cgroup ]; then
    21         exit 0
    22     fi
    23     if ! mountpoint -q /sys/fs/cgroup; then
    24         mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
    25     fi
    26     (
    27         cd /sys/fs/cgroup
    28         for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
    29             mkdir -p $sys
    30             if ! mountpoint -q $sys; then
    31                 if ! mount -n -t cgroup -o $sys cgroup $sys; then
    32                     rmdir $sys || true
    33                 fi
    34             fi
    35         done
    36     )
    37 end script
    38 
    39 script
    40     # modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
    41     DOCKERD=/usr/bin/dockerd
    42     DOCKER_OPTS=
    43     if [ -f /etc/default/$UPSTART_JOB ]; then
    44         . /etc/default/$UPSTART_JOB
    45     fi
    46     exec "$DOCKERD" $DOCKER_OPTS --raw-logs
    47 end script
    48 
    49 # Don't emit "started" event until docker.sock is ready.
    50 # See https://github.com/docker/docker/issues/6647
    51 post-start script
    52     DOCKER_OPTS=
    53     DOCKER_SOCKET=
    54     if [ -f /etc/default/$UPSTART_JOB ]; then
    55         . /etc/default/$UPSTART_JOB
    56     fi
    57 
    58     if ! printf "%s" "$DOCKER_OPTS" | grep -qE -e '-H|--host'; then
    59         DOCKER_SOCKET=/var/run/docker.sock
    60     else
    61         DOCKER_SOCKET=$(printf "%s" "$DOCKER_OPTS" | grep -oP -e '(-H|--host)W*unix://K(S+)' | sed 1q)
    62     fi
    63 
    64     if [ -n "$DOCKER_SOCKET" ]; then
    65         while ! [ -e "$DOCKER_SOCKET" ]; do
    66             initctl status $UPSTART_JOB | grep -qE "(stop|respawn)/" && exit 1
    67             echo "Waiting for $DOCKER_SOCKET"
    68             sleep 0.1
    69         done
    70         echo "$DOCKER_SOCKET is up"
    71     fi
    72 end script
    docker.conf

    /etc/init.d/docker

      1 #!/bin/sh
      2 set -e
      3 
      4 ### BEGIN INIT INFO
      5 # Provides:           docker
      6 # Required-Start:     $syslog $remote_fs
      7 # Required-Stop:      $syslog $remote_fs
      8 # Should-Start:       cgroupfs-mount cgroup-lite
      9 # Should-Stop:        cgroupfs-mount cgroup-lite
     10 # Default-Start:      2 3 4 5
     11 # Default-Stop:       0 1 6
     12 # Short-Description:  Create lightweight, portable, self-sufficient containers.
     13 # Description:
     14 #  Docker is an open-source project to easily create lightweight, portable,
     15 #  self-sufficient containers from any application. The same container that a
     16 #  developer builds and tests on a laptop can run at scale, in production, on
     17 #  VMs, bare metal, OpenStack clusters, public clouds and more.
     18 ### END INIT INFO
     19 
     20 export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
     21 
     22 BASE=docker
     23 
     24 # modify these in /etc/default/$BASE (/etc/default/docker)
     25 DOCKERD=/usr/bin/dockerd
     26 # This is the pid file managed by docker itself
     27 DOCKER_PIDFILE=/var/run/$BASE.pid
     28 # This is the pid file created/managed by start-stop-daemon
     29 DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid
     30 DOCKER_LOGFILE=/var/log/$BASE.log
     31 DOCKER_OPTS=
     32 DOCKER_DESC="Docker"
     33 
     34 # Get lsb functions
     35 . /lib/lsb/init-functions
     36 
     37 if [ -f /etc/default/$BASE ]; then
     38     . /etc/default/$BASE
     39 fi
     40 
     41 # Check docker is present
     42 if [ ! -x $DOCKERD ]; then
     43     log_failure_msg "$DOCKERD not present or not executable"
     44     exit 1
     45 fi
     46 
     47 check_init() {
     48     # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it directly)
     49     if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then
     50         log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1"
     51         exit 1
     52     fi
     53 }
     54 
     55 fail_unless_root() {
     56     if [ "$(id -u)" != '0' ]; then
     57         log_failure_msg "$DOCKER_DESC must be run as root"
     58         exit 1
     59     fi
     60 }
     61 
     62 cgroupfs_mount() {
     63     # see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
     64     if grep -v '^#' /etc/fstab | grep -q cgroup 
     65         || [ ! -e /proc/cgroups ] 
     66         || [ ! -d /sys/fs/cgroup ]; then
     67         return
     68     fi
     69     if ! mountpoint -q /sys/fs/cgroup; then
     70         mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
     71     fi
     72     (
     73         cd /sys/fs/cgroup
     74         for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
     75             mkdir -p $sys
     76             if ! mountpoint -q $sys; then
     77                 if ! mount -n -t cgroup -o $sys cgroup $sys; then
     78                     rmdir $sys || true
     79                 fi
     80             fi
     81         done
     82     )
     83 }
     84 
     85 case "$1" in
     86     start)
     87         check_init
     88         
     89         fail_unless_root
     90 
     91         cgroupfs_mount
     92 
     93         touch "$DOCKER_LOGFILE"
     94         chgrp docker "$DOCKER_LOGFILE"
     95 
     96         ulimit -n 1048576
     97 
     98         # Having non-zero limits causes performance problems due to accounting overhead
     99         # in the kernel. We recommend using cgroups to do container-local accounting.
    100         if [ "$BASH" ]; then
    101             ulimit -u unlimited
    102         else
    103             ulimit -p unlimited
    104         fi
    105 
    106         log_begin_msg "Starting $DOCKER_DESC: $BASE"
    107         start-stop-daemon --start --background 
    108             --no-close 
    109             --exec "$DOCKERD" 
    110             --pidfile "$DOCKER_SSD_PIDFILE" 
    111             --make-pidfile 
    112             -- 
    113                 -p "$DOCKER_PIDFILE" 
    114                 $DOCKER_OPTS 
    115                     >> "$DOCKER_LOGFILE" 2>&1
    116         log_end_msg $?
    117         ;;
    118 
    119     stop)
    120         check_init
    121         fail_unless_root
    122         if [ -f "$DOCKER_SSD_PIDFILE" ]; then
    123             log_begin_msg "Stopping $DOCKER_DESC: $BASE"
    124             start-stop-daemon --stop --pidfile "$DOCKER_SSD_PIDFILE" --retry 10
    125             log_end_msg $?
    126         else
    127             log_warning_msg "Docker already stopped - file $DOCKER_SSD_PIDFILE not found."
    128         fi
    129         ;;
    130 
    131     restart)
    132         check_init
    133         fail_unless_root
    134         docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null`
    135         [ -n "$docker_pid" ] 
    136             && ps -p $docker_pid > /dev/null 2>&1 
    137             && $0 stop
    138         $0 start
    139         ;;
    140 
    141     force-reload)
    142         check_init
    143         fail_unless_root
    144         $0 restart
    145         ;;
    146 
    147     status)
    148         check_init
    149         status_of_proc -p "$DOCKER_SSD_PIDFILE" "$DOCKERD" "$DOCKER_DESC"
    150         ;;
    151 
    152     *)
    153         echo "Usage: service docker {start|stop|restart|status}"
    154         exit 1
    155         ;;
    156 esac
    docker

    docker 镜像,网络等地址

  • 相关阅读:
    bert源码的文件、参数理解
    除了利用打印的方法保存colab,如何直接转化为图片(附使用tf自己预训练模型导入办法)
    sse、mse、rmse、 r-square
    我的开源之旅(也许中道崩卒哈哈哈)
    attention_utils无法导入
    那些天,shell脚本中曾经踩过的坑
    python通过webservice接口实现配置下发
    python源文件转换成exe问题解决贴
    suds库使用说明官方文档
    两个实用linux小工具
  • 原文地址:https://www.cnblogs.com/Michael2397/p/7285706.html
Copyright © 2020-2023  润新知