本人在docker hub上上传了自己用的基于ubuntu18.04搭建的openwrt编译环境,可以方便开发者快速搭建开发环境,而且以容器的方式独立于宿主机,好处多多.
镜像的简介:
1 2 3 4 5 | 本镜像基于ubuntu18.04,root密码123456 1、安装了openwrt编译环境需要依赖的软件包 2、替换了apt源为阿里源 3、支持终端中文显示和输入 4、新增了用户op,密码为123456 |
本文不会大篇幅讲解docker如何使用,但用到的docker命令会写出来,请自行百度docker的安装、配置和更多的命令
另外,openwrt下的dl文件夹中的软件包的下载一直不是很顺畅,我把我所有的dl下的软件包分享到百度云上了(不让我无密码分享,说是有敏感信息)链接链接: https://pan.baidu.com/s/1RzrglP6EwsPAXFfYHjkNuw 提取码: 14ts
正式开始介绍如何使用我的docker镜像
首先使用如下命令在dockerHUB上搜索我的镜像,返回的信息中siasjack/ubuntuopenwr就是我的镜像了
1 2 3 4 | # docker search ubuntuopenwrt NAME DESCRIPTION STARS OFFICIAL AUTOMATED doarcanjo/ubuntuopenwrt Ubuntu with dependencies 0 siasjack/ubuntuopenwrt 基于ubuntu18.04的openwrt编译环境,阿里源,中… 0 |
然后使用命令docker pull 命令把镜像拉下来,如下:
1 2 3 4 5 6 7 | # docker pull siasjack/ubuntuopenwrt Using default tag: latest latest: Pulling from siasjack/ubuntuopenwrt 8d128f5fac22: Pull complete Digest: sha256:a048bbf0989cef419bb84d42fb1fb41b623459ddfd9a62cde390fec20b1f11c2 Status: Downloaded newer image for siasjack/ubuntuopenwrt:latest docker.io/siasjack/ubuntuopenwrt:latest |
镜像有500M,下载需要点时间,请耐心等待。看到如上信息后说明下载完成了,此时使用docker images查看当前电脑上的所有镜像是否包含siasjack/ubuntuopenwrt
1 2 3 | siasjack@siasjack-VirtualBox:~/workspace$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE siasjack/ubuntuopenwrt latest c350b9dcc542 34 minutes ago 537MB |
如上信息就说明镜像pull成功了,可以启动容器了,docker run是创建并启动一个容器,docker start是启动一个已经存在的容器,docker stop是停止正在运行的容器,docker restart是重启容器
先来run一个容器,使用镜像siasjack/ubuntuopenwrt,容器取名u18op,容器默认运行的命令是/bin/bash:
1 2 3 4 5 6 | $ docker run -d -it --name u18op siasjack/ubuntuopenwrt /bin/bash 5eb1d432e4bc14169801cd2efa0554d1324f59933371cd49eb0ead7ff78b722e $ #查看是否创建成功,STATUS状态是否已经up $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5eb1d432e4bc siasjack/ubuntuopenwrt "/bin/bash" 5 seconds ago Up 3 seconds u18op |
如上容器已经创建成功,并已经UP了,我们可以用docker exec进入容器中做各种操作了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | siasjack@siasjack-VirtualBox:~/workspace$ docker exec -it u18op /bin/bash root@5eb1d432e4bc:/# root@5eb1d432e4bc:/# cd root@5eb1d432e4bc:~# cat readme.txt this is image baseon ubuntu 18.04 installed openwrt sdk depends software 1. root's passwd is 123456 2. there is another user op op's passwd is 123456 op is a sudo user 3. apt source.list has change to alibaba mirror 4. term has support zh_cn input root@5eb1d432e4bc:~# |
如上 已经进入容器内部了,git、svn、vim等命令已经安装,可以尽情使用了!!!
接下来就可以按照教程搭建openwrt的环境,省去那些安装依赖软件的步骤,https://www.openwrtdl.com/wordpress/openwrt-full-tutorial
也可以使用如下命令直接下载源码,注意要切换用户到op
1 2 3 4 5 6 7 8 9 | # su op $ cd $ 下载trunk分支(最新代码) $ git clone https://github.com/openwrt/openwrt.git openwrt $ #下载1806分支的代码 $ git clone -b openwrt-18.06 https://github.com/openwrt/openwrt.git openwrt1806 $ #下载19.07分支的代码 $ git clone -b openwrt-19.07 https://github.com/openwrt/openwrt.git openwrt1907 $ |
enjoy….
已转用github actions 编译了,参考https://github.com/P3TERX/Actions-OpenWrt
这玩意太牛逼了!!
多谢分享
我第一次看到这个!
op@c30691745d35:~$ pwd
/home/op
op@c30691745d35:~$ git clone git://git.openwrt.org/openwrt.git
fatal: 不能创建工作区目录 ‘openwrt’: 权限不够
我也发现了 是/home/op目录的权限问题 先用su root,然后chown -R op /home/op就可以了
感谢楼主无私分享,我的ubuntu18.04 docker搭建好了openwrt编译环境。已经到了make menuconfig图形编译页面。请问下楼主“接下来就可以按照教程搭建openwrt的环境,省去那些安装依赖软件的步骤,https://www.openwrtdl.com/wordpress/openwrt-full-tutorial”。这个教程指的是用于非docker搭建openwrt环境吧。
能走到这一步应该是依赖软件都安装了,但是不保证会有其他错误
直接make V=s编译看看就知道了
您好,我执行了make V=s .编译中报错误。make -r world: build failed. Please re-run make with -j1 V=s or V=sc for a higher verbosity level to see what’s going on
/home/op/openwrt/include/toplevel.mk:225: recipe for target ‘world’ failed
make: *** [world] Error 1
请问下是什么原因?怎么处理?谢谢
可以使用github action在线编译的,速度比自己电脑快。
您好,我又执行了make -j1 V=S .我仔细看了编译中的信息,有很多处提示在openwrt.org和github.com下载失败了。估计是国内网络环境问题。被墙了,我不知道怎么在ubuntu搭梯子。请专家告诉下办法,谢谢。
Build dependency: Please install Python >= 3.5
Build dependency: Please install Python >= 3.5
/home/op/openwrt/include/prereq.mk:12: recipe for target ‘prereq’ failed
Prerequisite check failed. Use FORCE=1 to override.
/home/op/openwrt/include/toplevel.mk:176: recipe for target ‘staging_dir/host/.prereq-build’ failed
make[2]: *** [staging_dir/host/.prereq-build] Error 1
/home/op/openwrt/include/toplevel.mk:83: recipe for target ‘prepare-tmpinfo’ failed
make[1]: *** [prepare-tmpinfo] Error 2
/home/op/openwrt/include/toplevel.mk:225: recipe for target ‘world’ failed
make: *** [world] Error 2
编译出错,怎么处理?
楼主,百度云的链接失效了,能再发一个吗 email 1503268993@qq.com
链接: https://pan.baidu.com/s/1RzrglP6EwsPAXFfYHjkNuw 提取码: 14ts 复制这段内容后打开百度网盘手机App,操作更方便哦