搭建开发环境

首先还是从centos入手吧

1
2
3
C:\Users\Administrator>docker search centos
NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
centos                             The official build of CentOS.                   5221                [OK]

选择一个官方的版本,pull下来

1
docker run -it centos

这是一个没有vim,没有gcc,没有gdb的世界,安装他们

1
2
3
yum install vim
yum install gcc
yum install gdb

于是在windows的docker下,我们可以继续愉快的code了。

–然而
实测发现gdb不能用

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@1bb163f86a43 lcl]# gdb hello
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /lcl/hello...done.
(gdb) l
1       #include <stdio.h>
2
3       int main()
4       {
5           printf("hello world!\n");
6           return 0;
7       }
(gdb) r
Starting program: /lcl/hello
warning: Error disabling address space randomization: Operation not permitted
Cannot create process: Operation not permitted
During startup program exited with code 127.

参考这篇
https://blog.csdn.net/snipercai/article/details/80408569

1
2
3
C:\Users\Administrator>docker ps -l
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
1bb163f86a43        centos/gcc          "/bin/bash"         45 minutes ago      Exited (0) 16 minutes ago                       pensive_ramanujan

记住这个ID,commit它

1
2
3
4
5
6
7
8
9
C:\Users\Administrator>docker commit 1bb develop
sha256:30f0327ebe65560ebd78daf868c1835c0d97ee1c2ff95450ec1ebd848cb57cc7

C:\Users\Administrator>docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
develop             latest              30f0327ebe65        6 seconds ago       493MB
centos/gcc          latest              f1af98e3ed8a        22 hours ago        408MB
centos              latest              1e1148e4cc2c        2 months ago        202MB
learn/tutorial      latest              a7876479f1aa        5 years ago         128MB

现在得到了images develop,以后就用它吧