docker exec

login docker container as root

$ docker run -d <image>:<tag>
$ docker exec --privileged -u root -it <image-id> /bin/bash

docker run

run into dind

$ docker run \
         --name "marslo" \
         --entrypoint /bin/bash \
         --privileged \
         --rm \
         -it \
         -v /var/run/docker.sock:/var/run/docker.sock \
         docker:dind

$ ubuntu@01acbffd94ec:~$ docker --version
Docker version 18.06.1-ce, build e68fc7a

run to override entrypoint

$ docker run \
         --name marslo \
         -it \
         --entrypoint /bin/bash \
         docker:dind

run commands to override entrypoint

$ docker run  \
         -it  \
         --rm \
         --entrypoint /bin/bash \
         docker:dind \
         -c 'cat /etc/*-release'

runtime options with memory, cpus, and gpus

reference:

Brief summary of control files

  • /sys/fs/cgroup/memory/docker/ID/memory.usage_in_bytes : show current usage for memory
  • /sys/fs/cgroup/memory/docker/ID/memory.limit_in_bytes : set/show limit of memory usage
  • /sys/fs/cgroup/cpuacct/docker/ID/cpuacct.usage : show the total CPU time (in nanoseconds) consumed by all tasks in this cgroup
  • /sys/fs/cgroup/cpuacct/docker/ID/cpuacct.stat : show the user and system CPU time consumed by all tasks in this cgroup
  • /sys/fs/cgroup/cpuacct/docker/ID/cpuacct.usage_percpu: show the CPU time (in nanoseconds) consumed on each CPU by all tasks in this cgroup

  • memory

    $ docker run \
             --name marslo \
             -it \
             --entrypoint /bin/bash \
             --memory=4G \
             --oom-kill-disable \         // optional
             docker:dind
    
  • cpu

    $ docker run \
             --name marslo \
             -it \
             --entrypoint /bin/bash \
             --cpus="4" \
             docker:dind
    

run with always restart

docker: Conflicting options: --restart and --rm.

$ docker run \
         -d \
         --name ss-libev \
         --restart=always \
         -p 8443:8443 \
         -p 8443:8443/udp \
         -v /etc/shadowsocks-libev:/etc/shadowsocks-libev \
         teddysun/shadowsocks-libev
  • visit via
    $ docker exec -it ss-libev /bin/sh
    
Copyright © marslo 2020-2024 all right reserved,powered by GitbookLast Modified: 2024-10-30 04:30:30

results matching ""

    No results matching ""