Docker and Docker Hub Notes - fordsfords/fordsfords.github.io GitHub Wiki

Trying to make a CentOS 5 build environment.

See also Things I forget#Docker_Stuff

Table of Contents

File Access

Mount a local folder to the container filesystem: Using this mount point as your container working directory, you'll persist locally any files created within the container and you'll make the container aware of any local changes made to project files.

Mac

The following was done on my personal Mac after installing Docker Desktop and running it. For clarity, I will include the prompts so that you know what is running at each point.

Create a directory "bld5" and "cd" to it. Then:

bld5 $ docker run --rm -i -t --name bld5 astj/centos5-vault /bin/bash

The terminal window is now running in the container's environment.

[root@b5c7b30415b9 /]# ls
bin  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  sbin  selinux  srv  sys  tmp  usr  var
[root@b5c7b30415b9 home]# gcc
bash: gcc: command not found
[root@b5c7b30415b9 home]# yum search gcc
...
gcc.x86_64 : Various compilers (C, C++, Objective-C, Java, ...)
...
[root@b5c7b30415b9 home]# yum install gcc.x86_64
...
[root@b5c7b30415b9 home]# ldd --version
ldd (GNU libc) 2.5

In a separate host window:

~ $ docker ps
CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS              PORTS               NAMES
b5c7b30415b9        astj/centos5-vault   "/bin/bash"         14 minutes ago      Up 14 minutes                           bld5

~ $ docker commit b5c7b30415b9

In the container window:

exit
[root@b5c7b30415b9 home]# exit
exit
bld5 $ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
bld5 $ docker container ls -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
bld5 $ docker images -a
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
<none>               <none>              582a5542f263        10 minutes ago      477MB
astj/centos5-vault   latest              e79faab040e1        2 years ago         284MB

Run it again:

bld5 $ docker run --rm -i -t --name bld5 582a5542f263 /bin/bash
[root@3d4149bdc8e9 /]# gcc
gcc: no input files
[root@3d4149bdc8e9 /]# exit
exit

Save it (see difference between export and save):

$ docker save 582a5542f263 | gzip -c >bld5v2.tz  # will take about 1 minute
$ ls -lh bld5v2.tz
-rw-r--r--  1 sford_itunes  staff   136M Jan 26 08:19 bld5v2.tz

CentOS 8

Good luck. I couldn't get it to work, but apparently others could.

CentOS 7

  • Install CentOS 7 "everything"
    • Select "minimal install" and add "development tools"
  • Do *not* do the "yum update".
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

sudo yum install -y docker-ce docker-ce-cli containerd.io

sudo systemctl start docker
sudo systemctl enable docker

sudo docker run --rm hello-world

gunzip -c <bld5v2.tz | sudo docker load
sudo docker images -a

sudo docker run --rm -i -t --name bld5 (image ID) /bin/bash

Fedora 31

Also, apparently the Fedora team upgraded to something called "CgroupsV2", which broke docker. According to reddit, you need to do the following:

sudo vi /etc/default/grub
Add systemd.unified_cgroup_hierarchy=0 to the GRUB_CMDLINE_LINUX. Mine ended up like this:
GRUB_CMDLINE_LINUX="resume=/dev/mapper/fedora_localhost--live-swap rd.lvm.lv=fedora_localhost-live/root rd.lvm.lv=fedora_localhost-live/swap systemd.unified_cgroup_hierarchy=0 rhgb quiet"
Write and quit. Then:
sudo grub2-mkconfig
sudo reboot now

Then:

sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

sudo yum install docker-ce docker-ce-cli containerd.io

sudo systemctl start docker
sudo systemctl enable docker

sudo docker run --rm hello-world

gunzip -c <bld5v2.tz | sudo docker load

sudo docker run --rm -i -t --name bld5 fordsfords/bld5:v2 /bin/bash

Commands

Docker base command

Images:

Containers:

Resources

  docker "base image" "from scratch" centos
⚠️ **GitHub.com Fallback** ⚠️