Skip to content

Instantly share code, notes, and snippets.

@prayagupa
Last active October 21, 2022 20:57
Show Gist options
  • Select an option

  • Save prayagupa/69bbecb33af8abed1583 to your computer and use it in GitHub Desktop.

Select an option

Save prayagupa/69bbecb33af8abed1583 to your computer and use it in GitHub Desktop.
vagrant, docker, docker-engine, container, hypervisor, libcontainer

Linux

#turn off proxy if needed.

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" >> /etc/apt/sources.list.d/docker.list

sudo apt-get update
sudo apt-get purge lxc-docker ##did not need it
apt-cache policy docker-engine ## just to see candidate installation

sudo apt-get upgrade

# linux-image-extra, for 16.04
sudo apt-get update
sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual ##only for ubuntu 16.04


###install
sudo apt-get update
sudo apt-get install docker-engine
sudo service docker start

##add current user to docker usergroup, verify with groups $USER, also reboot the machine
sudo gpasswd -a ${USER} docker
sudo service docker restart

docker won't be working if current user is not assigned to docker usergroup

prayag@prayag:~$ docker info
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

Cannot connect to the Docker daemon. Is the docker daemon running on this host?

prayag@prayag:~$ sudo service docker status
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2016-09-23 12:36:41 PDT; 1min 11s ago


After adding current user to docker group, followed by reboot, : aufs vs overlay2

docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.12.1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 0
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: host bridge null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 4.4.0-38-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 7.797 GiB
Name: mukti
ID: MABL:WSBY:2HFJ:7F66:LWGJ:7NG2:NSZA:UBSJ:5MNI:CCYV:NBVW:U3ZL
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Insecure Registries:
 127.0.0.0/8


##mac-os
docker info
Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 171
Server Version: 18.03.1-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.87-linuxkit-aufs
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: CH6S:VAZV:CQYA:BDGC:NR5Q:JE5C:F4W5:T2Q3:Y4SX:RGGO:M5IM:O5CB
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 21
 Goroutines: 39
 System Time: 2018-06-07T23:10:48.1764054Z
 EventsListeners: 2
HTTP Proxy: docker.for.mac.http.internal:3128
HTTPS Proxy: docker.for.mac.http.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

docker volumes

$ docker volume ls
DRIVER              VOLUME NAME
local               387466e56e6e76998f050de5278bd06108efe7583309388964ba88ac3319450c
local               4b4d907097f04ef528627d36b8404f722f9d68efd5e8d4d81b58c1da3b849cef
local               4d1a1bb08ea54392104251fb039d8b33c711c78327050fcebaa5965e9abdb965
local               5996a07b052f4facb6ffa7b44632bcfe57bd3047369b24d173e75913adf9cae2
local               75c978e13868512abe6a9c4f85f9ac6cf83e0d312fc1f48b71849ff8ced0df9d
local               77d20f7136af735d789e5ae6a1a7884688f036e86873fb0dadec592a4e363150
local               794d71d9643785eb9a0657319b8d5ed4cdebb352f191877100e4dd7d4c3be428
local               96fd0c85ce4e0b1bbe7ec4828f66c37ce5341a2165fc3272a7773cd7022f7fba
local               b0c85b9b0a14cd2a14f0b2a8943f6a36a1f71740575e3ef90341f436c94dbc1e
local               c73bb77589a9402501ac6e92d55cab4412223ad66d7b244b53714c75eeaf5990
local               e2feabd261df009e87c243f6b626a4dce90eab750453ec31f9b4db193bb9fe62
local               f51c23e93eae8040cb1e58a4cb76dc4b5339f8cabe917781d9c639f00fd131eb

docker volume inspect 387466e56e6e76998f050de5278bd06108efe7583309388964ba88ac3319450c
[
    {
        "CreatedAt": "2018-04-22T20:00:19Z",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/387466e56e6e76998f050de5278bd06108efe7583309388964ba88ac3319450c/_data",
        "Name": "387466e56e6e76998f050de5278bd06108efe7583309388964ba88ac3319450c",
        "Options": null,
        "Scope": "local"
    }
]

sources

https://docs.docker.com/engine/installation/linux/ubuntulinux/

https://scotch.io/tutorials/getting-started-with-docker

podman-compose up
Error: failed to parse query parameter 'version': "3.4.4": given version is not supported
Traceback (most recent call last):
  File "/Users/a1353612/miniconda3/lib/python3.9/site-packages/podman_compose.py", line 563, in assert_cnt_nets
    try: compose.podman.output([], "network", ["exists", net_name])
  File "/Users/a1353612/miniconda3/lib/python3.9/site-packages/podman_compose.py", line 820, in output
    return subprocess.check_output(cmd_ls)
  File "/Users/a1353612/miniconda3/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/Users/a1353612/miniconda3/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
    
$ podman-compose --version
['podman', '--version', '']
using podman version: 3.4.4
podman-composer version  1.0.3
podman --version 
podman version 3.4.4
exit code: 0

$ podman machine stop
$ podman machine rm

The following files will be deleted:

/Users/prayagupa/.ssh/podman-machine-default
/Users/prayagupa/.ssh/podman-machine-default.pub
/Users/prayagupa/.config/containers/podman/machine/qemu/podman-machine-default.ign
/Users/prayagupa/.local/share/containers/podman/machine/qemu/podman-machine-default_fedora-coreos-36.20221014.2.0-qemu.x86_64.qcow2
/Users/prayagupa/.config/containers/podman/machine/qemu/podman-machine-default.json


brew uninstall podman
$ podman machine init
$ podman machine start
INFO[0000] waiting for clients...                       
INFO[0000] listening tcp://127.0.0.1:7777               
INFO[0000] new connection from  to /var/folders/t0/d_6dzlq541v5tm9217k13wyx81n8sq/T/podman/qemu_podman-machine-default.sock 
Waiting for VM ...
Machine "podman-machine-default" started successfully

$ echo $SSH_AUTH_SOCK
/private/tmp/com.apple.launchd.R3KycXWSah/Listeners

$ podman machine ls
NAME                     VM TYPE     CREATED        LAST UP            CPUS        MEMORY      DISK SIZE
podman-machine-default*  qemu        2 minutes ago  Currently running  1           2.147GB     10.74GB

STEP 1 download linux 64bit vagrant from https://www.vagrantup.com/downloads.html

STEP 2.

sudo dpkg -i vagrant_1.7.1_x86_64.deb

STEP 3. init a project

mkdir programmer-mattress
vagrant init
/opt/vagrant/bin/../embedded/gems/gems/vagrant-1.7.1/lib/vagrant/pre-rubygems.rb:31: warning: Insecure world writable dir /usr/local/jdk1.7.0_05/bin in PATH, mode 040777
/opt/vagrant/embedded/gems/gems/bundler-1.7.9/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /usr/local/jdk1.7.0_05/bin in PATH, mode 040777
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

STEP 4. add box to Vagrant

vagrant box add hashicorp/precise64

/opt/vagrant/bin/../embedded/gems/gems/vagrant-1.7.1/lib/vagrant/pre-rubygems.rb:31: warning: Insecure world writable dir /usr/local/jdk1.7.0_05/bin in PATH, mode 040777
/opt/vagrant/embedded/gems/gems/bundler-1.7.9/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /usr/local/jdk1.7.0_05/bin in PATH, mode 040777
==> box: Loading metadata for box 'hashicorp/precise64'
    box: URL: https://atlas.hashicorp.com/hashicorp/precise64
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) hyperv
2) virtualbox
3) vmware_fusion

Enter your choice: 2
==> box: Adding box 'hashicorp/precise64' (v1.1.0) for provider: virtualbox
    box: Downloading: https://atlas.hashicorp.com/hashicorp/boxes/precise64/versions/1.1.0/providers/virtualbox.box
==> box: Successfully added box 'hashicorp/precise64' (v1.1.0) for 'virtualbox'!

note : vagrant init centos/7 in windows 7 is not working, maybe because of private network access/ proxy

to setup the box manually

wget https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/14.04/providers/virtualbox.box
vagrant box add trusty-box ~/Downloads/trusty-server-cloudimg-amd64-vagrant-disk1.box
vagrant init trusty-box
vagrant up

STEP 5. use the added box

Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"
end

## also turn on ui
  config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
      vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  end

STEP 6. boot vagrant environment (PROVISION)

vagrant up
vagrant reload --provision

STEP 7. destroy the vagrant machine

vagrant destroy

References

https://docs.vagrantup.com/v2/getting-started

@prayagupa
Copy link
Copy Markdown
Author

prayagupa commented Sep 15, 2016

@prayagupa
Copy link
Copy Markdown
Author

prayagupa commented Mar 22, 2017

docker run -it --rm -p 8888:8080 tomcat:8.0
$ curl -X GET localhost:8888 -i
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Date: Wed, 22 Mar 2017 10:44:35 GMT
alias all-containers='docker ps -aq'
alias all-images='docker images -q'

@prayagupa
Copy link
Copy Markdown
Author

## remove docker
echo "------ removing docker ------------"
rm -rf /Applications/Docker\ 2.app/
rm -rf ~/Library/Application\ Scripts/group.com.docker/
rm -rf ~/Library/Containers/
rm -rf ~/.docker
rm -rf ~/Library/Preferences/com.docker.docker.plist
rm -rf ~/Library/Saved\ Application\ State/com.electron.docker-frontend.savedState
rm -rf /Library/PrivilegedHelperTools/com.docker.vmnetd
rm -rf /Library/LaunchDaemons/com.docker.vmnetd.plist
rm -rf /usr/local/lib/docker
rm -rf ~/Library/Group\ Containers/group.com.docker
rm -rf ~/Library/Preferences/com.electron.docker-frontend.plist
rm -rf ~/Library/Cookies/com.docker.docker.binarycookies
rm -rf ~/Library/Application\ Support/Docker\ Desktop
echo ""
echo "------ docker removed ------------"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment