Buildroot Docker Notes


Posted by on January 29, 2019, modified on February 20, 2019

摘要 >


Build Tips >

CGROUPS for Docker >

Dockerd initial script >

SSH Server Config >

/etc/ssh/sshd_config

PermitRootLogin yes
PasswordAuthentication yes
PermitEmptyPasswords yes

Remember to restart sshd…

/etc/init.d/S50sshd restart

You can set root password empty, because of above configuation.

touch pwd
passwd root < ./pwd

Buildroot testing iso image >

You have to follow the steps as below to enable configuration to build iso file. Then, you can use it to test Virtualbox.

Docker login problem (Solved) >

Problem: when docker login, I met as below…

docker login
WARN[2019-01-29T06:57:34.928602543Z] failed to retrieve runc version: unknown output format: runc version commit: v1.0.0-rc6
spec: 1.0.1-dev
 
WARN[2019-01-29T06:57:34.929702404Z] failed to retrieve docker-init version: exec: "docker-init": executable file not found in $PATH 
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: bearout
Password: 
INFO[2019-01-29T06:57:41.245019014Z] Error logging in to v2 endpoint, trying next endpoint: Get https://registry-1.docker.io/v2/: x509: certificate signed by unknown authority 
ERRO[2019-01-29T06:57:41.247284107Z] Handler for POST /v1.39/auth returned error: Get https://registry-1.docker.io/v2/: x509: certificate signed by unknown authority 
Error response from daemon: Get https://registry-1.docker.io/v2/: x509: certificate signed by unknown authority

After ca-certificates installed, this problem can be resolved.

openssl genrsa -out client.key 4096
openssl req -new -x509 -text -key client.key -out client.cert
openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key -x509 -days 365 -out certs/domain.crt

OpenWRT Image Testing>

Import openwrt x86 rootfs.

$ docker import http://downloads.openwrt.org/attitude_adjustment/12.09/x86/generic/openwrt-x86-generic-rootfs.tar.gz openwrt-x86-generic-rootfs
$ docker images
REPOSITORY                           TAG                   IMAGE ID            CREATED             VIRTUAL SIZE
openwrt-x86-generic-rootfs           latest                2cebd16f086c        6 minutes ago       5.283 MB

Run shell for docker image, and mapping /tmp/test folder for some usage.

$ docker run --name test --rm -v /tmp/test:/tmp/test -it openwrt-x86-generic-rootfs /bin/ash

After enter OpenWRT shell, you can modify inittab and some config files.

inittab:

::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown
# Add for console. 
console::askfirst:/bin/ash --login
# Mark below lines. 
#ttyS0::askfirst:/bin/ash --login
#tty1::askfirst:/bin/ash --logi

Change the uhttpd listen ports to 8080 and 8443.

/etc/config/uhttpd:

config uhttpd 'main'
        option home '/www'
        option rfc1918_filter '1'
        option max_requests '3'
        option cert '/etc/uhttpd.crt'
        option key '/etc/uhttpd.key'
        option cgi_prefix '/cgi-bin'
        option script_timeout '60'
        option network_timeout '30'
        option tcp_keepalive '1'
        option listen_https '0.0.0.0:8443'
        option listen_http '0.0.0.0:8080'
...

Change the ssh listen port to 2222. /etc/config/dropbear:

config dropbear
        option PasswordAuth 'on'
        option RootPasswordAuth 'on'
        option Port '2222'

Then, copy /etc to /tmp/test.

$ cp -a /etc /tmp/test

Finally, run whole service on OpenWRT.

$ docker run --name test --rm -v /tmp/test/etc:/etc --privileged -it openwrt-x86-generic-rootfs /sbin/init
本站總訪問量訪客