- Comprehensive Blog on Dockers running on OCI
- running a Docker Container on OCI
- opening OCI Ports for Docker Containers
- Building a Docker Image by using Dockerfile
- Committing changes made in a Docker without using Dockerfile
- Pushing Docker Images to Docker Hub
- DevOps with Github, Docker Hub and Oracle Container Cloud Services
Creating a plane vanilla Ubuntu VM on OCI
please refer the following link how to create Ubuntu 18.04 OCI VM and SSH to the instance
Installing Docker on Ubuntu
oracle@oracle:~/BM$ ssh -i bm_ssh_key ubuntu@public_ip_address Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-36-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Tue Nov 6 07:32:08 UTC 2018 ubuntu@dockervm:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic
Add the Docker Repository
ubuntu@dockervm:~$ sudo apt install apt-transport-https ca-certificates curl software-properties-common Reading package lists... Done Building dependency tree Reading state information... Done ca-certificates is already the newest version (20180409). software-properties-common is already the newest version (0.96.24.32.5). The following package was automatically installed and is no longer required: grub-pc-bin Use 'sudo apt autoremove' to remove it. The following additional packages will be installed: libcurl4 The following NEW packages will be installed: apt-transport-https The following packages will be upgraded: curl libcurl4 2 upgraded, 1 newly installed, 0 to remove and 57 not upgraded. Need to get 374 kB of archives. After this operation, 152 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic-updates /universe amd64 apt-transport-https all 1.6.6 [1692 B] Get:2 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic-updates /main amd64 curl amd64 7.58.0-2ubuntu3.5 [159 kB] Get:3 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic-updates /main amd64 libcurl4 amd64 7.58.0-2ubuntu3.5 [214 kB] Fetched 374 kB in 1s (451 kB/s) Selecting previously unselected package apt-transport-https. (Reading database ... 67088 files and directories currently installed.) Preparing to unpack .../apt-transport-https_1.6.6_all.deb ... Unpacking apt-transport-https (1.6.6) ... Preparing to unpack .../curl_7.58.0-2ubuntu3.5_amd64.deb ... Unpacking curl (7.58.0-2ubuntu3.5) over (7.58.0-2ubuntu3.3) ... Preparing to unpack .../libcurl4_7.58.0-2ubuntu3.5_amd64.deb ... Unpacking libcurl4:amd64 (7.58.0-2ubuntu3.5) over (7.58.0-2ubuntu3.3) ... Setting up apt-transport-https (1.6.6) ... Setting up libcurl4:amd64 (7.58.0-2ubuntu3.5) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for man-db (2.8.3-2) ... Setting up curl (7.58.0-2ubuntu3.5) ... ubuntu@dockervm:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - OK ubuntu@dockervm:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" Hit:1 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic InRelease Hit:2 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic-updates InRelease Get:3 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB] Hit:4 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic-backports InRelease Hit:5 http://security.ubuntu.com/ubuntu bionic-security InRelease Get:6 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages [2414 B] Fetched 66.9 kB in 1s (103 kB/s) Reading package lists... Done
Install Docker and Check Status.
ubuntu@dockervm:~$ sudo apt update Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease Hit:2 https://download.docker.com/linux/ubuntu bionic InRelease Hit:3 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic InRelease Hit:4 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic-updates InRelease Hit:5 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic-backports InRelease Reading package lists... Done Building dependency tree Reading state information... Done 57 packages can be upgraded. Run 'apt list --upgradable' to see them. ubuntu@dockervm:~$ apt-cache policy docker-ce docker-ce: Installed: (none) Candidate: 18.06.1~ce~3-0~ubuntu Version table: 18.06.1~ce~3-0~ubuntu 500 500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages 18.06.0~ce~3-0~ubuntu 500 500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages 18.03.1~ce~3-0~ubuntu 500 500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages ubuntu@dockervm:~$ sudo apt install docker-ce Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: grub-pc-bin Use 'sudo apt autoremove' to remove it. The following additional packages will be installed: aufs-tools cgroupfs-mount libltdl7 pigz The following NEW packages will be installed: aufs-tools cgroupfs-mount docker-ce libltdl7 pigz 0 upgraded, 5 newly installed, 0 to remove and 57 not upgraded. Need to get 40.4 MB of archives. After this operation, 199 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic/universe amd64 pigz amd64 2.4-1 [57.4 kB] Get:2 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic/universe amd64 aufs-tools amd64 1:4.9+20170918-1ubuntu1 [104 kB] Get:3 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic/universe amd64 cgroupfs-mount all 1.4 [6320 B] Get:4 http://iad-ad-3.clouds.archive.ubuntu.com/ubuntu bionic/main amd64 libltdl7 amd64 2.4.6-2 [38.8 kB] Get:5 https://download.docker.com/linux/ubuntu bionic/stable amd64 docker-ce amd64 18.06.1~ce~3-0~ubuntu [40.2 MB] Fetched 40.4 MB in 5s (7587 kB/s) Selecting previously unselected package pigz. (Reading database ... 67092 files and directories currently installed.) Preparing to unpack .../archives/pigz_2.4-1_amd64.deb ... Unpacking pigz (2.4-1) ... Selecting previously unselected package aufs-tools. Preparing to unpack .../aufs-tools_1%3a4.9+20170918-1ubuntu1_amd64.deb ... Unpacking aufs-tools (1:4.9+20170918-1ubuntu1) ... Selecting previously unselected package cgroupfs-mount. Preparing to unpack .../cgroupfs-mount_1.4_all.deb ... Unpacking cgroupfs-mount (1.4) ... Selecting previously unselected package libltdl7:amd64. Preparing to unpack .../libltdl7_2.4.6-2_amd64.deb ... Unpacking libltdl7:amd64 (2.4.6-2) ... Selecting previously unselected package docker-ce. Preparing to unpack .../docker-ce_18.06.1~ce~3-0~ubuntu_amd64.deb ... Unpacking docker-ce (18.06.1~ce~3-0~ubuntu) ... Setting up aufs-tools (1:4.9+20170918-1ubuntu1) ... Processing triggers for ureadahead (0.100.0-20) ... Setting up cgroupfs-mount (1.4) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for systemd (237-3ubuntu10.3) ... Setting up libltdl7:amd64 (2.4.6-2) ... Processing triggers for man-db (2.8.3-2) ... Setting up pigz (2.4-1) ... Setting up docker-ce (18.06.1~ce~3-0~ubuntu) ... Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service. Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket. Processing triggers for ureadahead (0.100.0-20) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for systemd (237-3ubuntu10.3) ... ubuntu@dockervm:~$ sudo systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2018-11-06 06:21:47 UTC; 12s ago Docs: https://docs.docker.com Main PID: 3947 (dockerd) Tasks: 23 CGroup: /system.slice/docker.service ├─3947 /usr/bin/dockerd -H fd:// └─3971 docker-containerd --config /var/run/docker/containerd/containerd.toml Nov 06 06:21:46 dockervm dockerd[3947]: time="2018-11-06T06:21:46.517711032Z" level=info msg="ClientConn switching balancer to \"pick_first\"" m Nov 06 06:21:46 dockervm dockerd[3947]: time="2018-11-06T06:21:46.517770514Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc42 Nov 06 06:21:46 dockervm dockerd[3947]: time="2018-11-06T06:21:46.518212692Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc42 Nov 06 06:21:46 dockervm dockerd[3947]: time="2018-11-06T06:21:46.518247036Z" level=info msg="Loading containers: start." Nov 06 06:21:46 dockervm dockerd[3947]: time="2018-11-06T06:21:46.775742140Z" level=info msg="Default bridge (docker0) is assigned with an IP ad Nov 06 06:21:46 dockervm dockerd[3947]: time="2018-11-06T06:21:46.848607563Z" level=info msg="Loading containers: done." Nov 06 06:21:46 dockervm dockerd[3947]: time="2018-11-06T06:21:46.916407938Z" level=info msg="Docker daemon" commit=e68fc7a graphdriver(s)=overl Nov 06 06:21:46 dockervm dockerd[3947]: time="2018-11-06T06:21:46.916566072Z" level=info msg="Daemon has completed initialization" Nov 06 06:21:47 dockervm dockerd[3947]: time="2018-11-06T06:21:47.046244194Z" level=info msg="API listen on /var/run/docker.sock" Nov 06 06:21:47 dockervm systemd[1]: Started Docker Application Container Engine.
Checking Docker Commands
ubuntu@dockervm:~$ docker run --help Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Run a command in a new container Options: --add-host list Add a custom host-to-IP mapping (host:ip) -a, --attach list Attach to STDIN, STDOUT or STDERR --blkio-weight uint16 Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0) --blkio-weight-device list Block IO weight (relative device weight) (default []) --cap-add list Add Linux capabilities --cap-drop list Drop Linux capabilities --cgroup-parent string Optional parent cgroup for the container --cidfile string Write the container ID to the file --cpu-count int CPU count (Windows only) --cpu-percent int CPU percent (Windows only) --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota --cpu-rt-period int Limit CPU real-time period in microseconds --cpu-rt-runtime int Limit CPU real-time runtime in microseconds -c, --cpu-shares int CPU shares (relative weight) --cpus decimal Number of CPUs --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) --cpuset-mems string MEMs in which to allow execution (0-3, 0,1) -d, --detach Run container in background and print container ID --detach-keys string Override the key sequence for detaching a container --device list Add a host device to the container --device-cgroup-rule list Add a rule to the cgroup allowed devices list --device-read-bps list Limit read rate (bytes per second) from a device (default []) --device-read-iops list Limit read rate (IO per second) from a device (default []) --device-write-bps list Limit write rate (bytes per second) to a device (default []) --device-write-iops list Limit write rate (IO per second) to a device (default []) --disable-content-trust Skip image verification (default true) --dns list Set custom DNS servers --dns-option list Set DNS options --dns-search list Set custom DNS search domains --entrypoint string Overwrite the default ENTRYPOINT of the image -e, --env list Set environment variables --env-file list Read in a file of environment variables --expose list Expose a port or a range of ports --group-add list Add additional groups to join --health-cmd string Command to run to check health --health-interval duration Time between running the check (ms|s|m|h) (default 0s) --health-retries int Consecutive failures needed to report unhealthy --health-start-period duration Start period for the container to initialize before starting health-retries countdown (ms|s|m|h) (default 0s) --health-timeout duration Maximum time to allow one check to run (ms|s|m|h) (default 0s) --help Print usage -h, --hostname string Container host name --init Run an init inside the container that forwards signals and reaps processes -i, --interactive Keep STDIN open even if not attached --io-maxbandwidth bytes Maximum IO bandwidth limit for the system drive (Windows only) --io-maxiops uint Maximum IOps limit for the system drive (Windows only) --ip string IPv4 address (e.g., 172.30.100.104) --ip6 string IPv6 address (e.g., 2001:db8::33) --ipc string IPC mode to use --isolation string Container isolation technology --kernel-memory bytes Kernel memory limit -l, --label list Set meta data on a container --label-file list Read in a line delimited file of labels --link list Add link to another container --link-local-ip list Container IPv4/IPv6 link-local addresses --log-driver string Logging driver for the container --log-opt list Log driver options --mac-address string Container MAC address (e.g., 92:d0:c6:0a:29:33) -m, --memory bytes Memory limit --memory-reservation bytes Memory soft limit --memory-swap bytes Swap limit equal to memory plus swap: '-1' to enable unlimited swap --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) --mount mount Attach a filesystem mount to the container --name string Assign a name to the container --network string Connect a container to a network (default "default") --network-alias list Add network-scoped alias for the container --no-healthcheck Disable any container-specified HEALTHCHECK --oom-kill-disable Disable OOM Killer --oom-score-adj int Tune host's OOM preferences (-1000 to 1000) --pid string PID namespace to use --pids-limit int Tune container pids limit (set -1 for unlimited) --platform string Set platform if server is multi-platform capable --privileged Give extended privileges to this container -p, --publish list Publish a container's port(s) to the host -P, --publish-all Publish all exposed ports to random ports --read-only Mount the container's root filesystem as read only --restart string Restart policy to apply when a container exits (default "no") --rm Automatically remove the container when it exits --runtime string Runtime to use for this container --security-opt list Security Options --shm-size bytes Size of /dev/shm --sig-proxy Proxy received signals to the process (default true) --stop-signal string Signal to stop a container (default "SIGTERM") --stop-timeout int Timeout (in seconds) to stop a container --storage-opt list Storage driver options for the container --sysctl map Sysctl options (default map[]) --tmpfs list Mount a tmpfs directory -t, --tty Allocate a pseudo-TTY --ulimit ulimit Ulimit options (default []) -u, --user string Username or UID (format: <name|uid>[:<group|gid>]) --userns string User namespace to use --uts string UTS namespace to use -v, --volume list Bind mount a volume --volume-driver string Optional volume driver for the container --volumes-from list Mount volumes from the specified container(s) -w, --workdir string Working directory inside the container ubuntu@dockervm:~$ docker Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Options: --config string Location of client config files (default "/home/ubuntu/.docker") -D, --debug Enable debug mode -H, --host list Daemon socket(s) to connect to -l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info") --tls Use TLS; implied by --tlsverify --tlscacert string Trust certs signed only by this CA (default "/home/ubuntu/.docker/ca.pem") --tlscert string Path to TLS certificate file (default "/home/ubuntu/.docker/cert.pem") --tlskey string Path to TLS key file (default "/home/ubuntu/.docker/key.pem") --tlsverify Use TLS and verify the remote -v, --version Print version information and quit Management Commands: config Manage Docker configs container Manage containers image Manage images network Manage networks node Manage Swarm nodes plugin Manage plugins secret Manage Docker secrets service Manage services stack Manage Docker stacks swarm Manage Swarm system Manage Docker trust Manage trust on Docker images volume Manage volumes Commands: attach Attach local standard input, output, and error streams to a running container build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container deploy Deploy a new stack or update an existing stack diff Inspect changes to files or directories on a container's filesystem events Get real time events from the server exec Run a command in a running container export Export a container's filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on Docker objects kill Kill one or more running containers load Load an image from a tar archive or STDIN login Log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container ps List containers pull Pull an image or a repository from a registry push Push an image or a repository to a registry rename Rename a container restart Restart one or more containers rm Remove one or more containers rmi Remove one or more images run Run a command in a new container save Save one or more images to a tar archive (streamed to STDOUT by default) search Search the Docker Hub for images start Start one or more stopped containers stats Display a live stream of container(s) resource usage statistics stop Stop one or more running containers tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE top Display the running processes of a container unpause Unpause all processes within one or more containers update Update configuration of one or more containers version Show the Docker version information wait Block until one or more containers stop, then print their exit codes Run 'docker COMMAND --help' for more information on a command. ubuntu@dockervm:~$ docker docker-subcommand --help Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Options: --config string Location of client config files (default "/home/ubuntu/.docker") -D, --debug Enable debug mode -H, --host list Daemon socket(s) to connect to -l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info") --tls Use TLS; implied by --tlsverify --tlscacert string Trust certs signed only by this CA (default "/home/ubuntu/.docker/ca.pem") --tlscert string Path to TLS certificate file (default "/home/ubuntu/.docker/cert.pem") --tlskey string Path to TLS key file (default "/home/ubuntu/.docker/key.pem") --tlsverify Use TLS and verify the remote -v, --version Print version information and quit Management Commands: config Manage Docker configs container Manage containers image Manage images network Manage networks node Manage Swarm nodes plugin Manage plugins secret Manage Docker secrets service Manage services stack Manage Docker stacks swarm Manage Swarm system Manage Docker trust Manage trust on Docker images volume Manage volumes Commands: attach Attach local standard input, output, and error streams to a running container build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container deploy Deploy a new stack or update an existing stack diff Inspect changes to files or directories on a container's filesystem events Get real time events from the server exec Run a command in a running container export Export a container's filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on Docker objects kill Kill one or more running containers load Load an image from a tar archive or STDIN login Log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container ps List containers pull Pull an image or a repository from a registry push Push an image or a repository to a registry rename Rename a container restart Restart one or more containers rm Remove one or more containers rmi Remove one or more images run Run a command in a new container save Save one or more images to a tar archive (streamed to STDOUT by default) search Search the Docker Hub for images start Start one or more stopped containers stats Display a live stream of container(s) resource usage statistics stop Stop one or more running containers tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE top Display the running processes of a container unpause Unpause all processes within one or more containers update Update configuration of one or more containers version Show the Docker version information wait Block until one or more containers stop, then print their exit codes Run 'docker COMMAND --help' for more information on a command. ubuntu@dockervm:~$ docker info Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.38/info: dial unix /var/run/docker.sock: connect: permission denied ubuntu@dockervm:~$ sudo docker info Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 18.06.1-ce ..
Removing Sudo to run Docker Commands
ubuntu@dockervm:~$ sudo usermod -a -G docker $USER disconnect from SSH session and relogin ubuntu@dockervm:~$ docker info Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 18.06.1-ce ...