Docker for mac configure swap space

I am trying to build this image: https://github.com/oracle/docker-images/tree/master/OracleDatabase on Docker for mac 1.12.1-rc1-beta23 , but the build process fail because of the swap space memory is not enough for the oracle xe installation, so I want to know if its possible change the swap on hyperkit vm .The error message:

Step 9 : RUN unzip $INSTALL_FILE_1 && rm $INSTALL_FILE_1 && rpm -i Disk1/*.rpm && sed -i -e “s|###ORACLE_PWD###|$ORACLE_PWD|g” $INSTALL_DIR/$CONFIG_RSP && /etc/init.d/oracle-xe configure responseFile=$CONFIG_RSP && mv $INSTALL_DIR/$RUN_FILE $ORACLE_BASE/ && rm -rf $INSTALL_DIR && chown -R oracle:dba $ORACLE_BASE && chmod u+x $ORACLE_BASE/$RUN_FILE
—> Running in 5b89c2c5b1ab
Archive: oracle-xe-11.2.0-1.0.x86_64.rpm.zip
creating: Disk1/
creating: Disk1/upgrade/
inflating: Disk1/upgrade/gen_inst.sql
creating: Disk1/response/
inflating: Disk1/response/xe.rsp
inflating: Disk1/oracle-xe-11.2.0-1.0.x86_64.rpm

This system does not meet the minimum requirements for swap space. Based on
the amount of physical memory available on the system, Oracle Database 11g
Express Edition requires 2048 MB of swap space. This system has 964 MB
of swap space. Configure more swap space on the system and retry the
installation.

error: %pre(oracle-xe-11.2.0-1.0.x86_64) scriptlet failed, exit status 1
error: oracle-xe-11.2.0-1.0.x86_64: install failed

docker version output:

Client:
Version: 1.12.1-rc1
API version: 1.24
Go version: go1.6.3
Git commit: 7889dc7
Built: Fri Aug 12 18:35:53 2016
OS/Arch: darwin/amd64
Experimental: true

Server:
Version: 1.12.1-rc1
API version: 1.24
Go version: go1.6.3
Git commit: 7889dc7
Built: Fri Aug 12 18:35:53 2016
OS/Arch: linux/amd64
Experimental: true

Docker info output:

Containers: 2
Running: 0
Paused: 0
Stopped: 2
Images: 65
Server Version: 1.12.1-rc1
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 42
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: null overlay bridge host
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.17-moby
Operating System: Alpine Linux v3.4
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 5.819 GiB
Name: moby
ID: F473:DDT7:CLOK:AXUI:34IV:76ZI:5H5K:C63H:G77I:BN4L:ZFZO:I3ZS
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 17
Goroutines: 28
System Time: 2016-08-18T11:56:15.21051943Z
EventsListeners: 1
No Proxy: *.local, 169.254/16
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
127.0.0.0/8

I found a solution,thanks to this topic Change Docker for Mac Engine /etc files - #2 by iconara , the only thing I needed to do to access the docker host was use this command:

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
username:root
password:[empty]
close session:Ctrl+a d

To change the swap size for oracle xe installation:

dd if=/dev/zero of=/var/swap.file count=2000000 bs=1024
chmod go= /var/swap.file
mkswap /var/swap.file
echo “/var/swap.file swap swap defaults 0 0” >> /etc/fstab

1 Like

Hi ramonpires

For me the solution did not work for docker toolbox on Mac OS Sierra.
Using the proposed solution I got rid of the swap space issue but got into the No space left on device I didn’t managed to fix.
For me the only way I managed to fix the issue was to increase the memory of the VBox to 8GB (as per the suggestion offered at Unable to create Oracle Image · Issue #2 · sciabarra/sites12c-docker · GitHub )

docker-machine stop dev
VBoxManage modifyvm dev --memory 8192
docker-machine start dev

Maybe I did something wrong during my attempt to fix the problem with the your proposal, taken into account I had to adapt it a bit (I used the docker-machine ssh dev instead of screen … command)

jtonic

@jtonic I’m using docker for mac,which is more lightweight than docker tools stack, you should give a try.

I’m trying to solve the same problem on Docker 1.13 without any luck.

I did the following:

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
(I’m not prompted for login and I’m already root)

dd if=/dev/zero of=/var/swap.file count=2000000 bs=1024
chmod go= /var/swap.file
mkswap /var/swap.file
echo “/var/swap.file swap swap defaults 0 0” >> /etc/fstab

close session:Ctrl+a d

Then, if I retry to build my image I get the same error about the swap size:

This system does not meet the minimum requirements for swap space. Based on
the amount of physical memory available on the system, Oracle Database 11g
Express Edition requires 2048 MB of swap space. This system has 964 MB
of swap space. Configure more swap space on the system and retry the
installation.

docker info:

Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 71
Server Version: 1.13.0
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 68
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 03e5862ec0d8d3b3f750e19fca3ee367e13c090e
runc version: 2f7393a47307a16f8cee44a37b262e8b81021e3e
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.4-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952 GiB
Name: moby
ID: UXQN:ZPVH:RSQJ:5VRF:NW6J:EV6J:VOW7:XZ3B:KKNW:KBFK:55VZ:XI2M
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 16
Goroutines: 26
System Time: 2017-03-22T08:45:43.822467337Z
EventsListeners: 1
No Proxy: *.local, 169.254/16
Username: xxx
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

@nicolimo86 Did you restarted your docker host? If you restart your docker host, all swap configuration will be lost.

No I didn’t, I’ve just closed the screen session like this:

close session:Ctrl+a d

@nicolimo86 I don’t know why it’s happening , try to increase the ram of docker host to 3 GB before the swap configuration process.

  • I set the memory to 3GB (restart included).
  • I ve repetead the steps to increase the swap size. (no restart)
  • the problem is exactly the same.

The size of the swap area doesn’t seem to be affected from any of the previous actions:

This system has 964 MB
of swap space

@nicolimo86 after execute this command:
echo "/var/swap.file swap swap defaults 0 0" >> /etc/fstab
Execute another command:
swapon -a
To know if the swap size was increased ,type swapon and will show this output:

/dev/vda2      partition 964.8M   0B   -1
/var/swap.file file        1.9G   0B   -2``` 

You can shrink again your docker host ram to the previous value.

I’ve executed swapon -a

Then, I had to use this altervative approach to get the list of the swap files:

$cat /proc/swaps
Filename Type Size Used Priority
/dev/sda2 partition 987960 0 -1
/var/swap.file file 1999996 0 -2

swapon returns only this:

$swapon
BusyBox v1.25.1 (2016-10-26 16:15:20 GMT) multi-call binary.

Usage: swapon [-a] [-e] [-d[POL]] [-p PRI] [DEVICE]

Start swapping on DEVICE

    -a      Start swapping on all swap devices
    -d[POL] Discard blocks at swapon (POL=once),
            as freed (POL=pages), or both (POL omitted)
    -e      Silently skip devices that do not exist
    -p PRI  Set swap device priority

@nicolimo86 try again the build process , without restart the docker host.

@ramonpires thanks a lot, now it works!:wink:

Just to summarize for the others, the solution in my case was the following:

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
dd if=/dev/zero of=/var/swap.file count=2000000 bs=1024
chmod go= /var/swap.file
mkswap /var/swap.file
echo “/var/swap.file swap swap defaults 0 0” >> /etc/fstab
swapon -a

Sorry @nicolimo86 , I’ve just forgot to add the swapon -a step on my solution.