0

I just started learning Docker and trying to build a C++ project for Windows on Ubuntu. For that I use this project which almost works, but I have linking error, particularly it fails to link against libssh.

I run the build of my project using this command:

sudo docker run -v $PWD:/project/source -v $PWD/build_docker:/project/build my_qt_cross_win:qttools

where my_qt_cross_win:qttools is the image that I built by git cloning original repo and added some missing libraries.

Since building it takes 2 hours, because it builds the whole system, and I just need to fix this minor linking issue, I would like to just add the proper libssh.a to the container that was instanced from my_qt_cross_win:qttools image and build my project using that modified container. But it feels like I can use only images for that, because docker complains

Unable to find image 'musing_chebyshev:latest' locally

when I try to use container name or id instead of an image.

$ sudo docker container ps -a                                                                                                                                             
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS                      PORTS               NAMES
d207fd2d9dd8        my_qt_cross_win:qttools     "/bin/sh -c 'qmake /…"   11 minutes ago      Exited (2) 10 minutes ago                       musing_chebyshev

Is there any way I can use a modified container to build my project?

Alan Birtles
  • 32,622
  • 4
  • 31
  • 60
rightaway717
  • 2,631
  • 3
  • 29
  • 43
  • not really programming related, `docker run` creates a new container. You want [`docker start`](https://docs.docker.com/engine/reference/commandline/start/) to resume your existing container – Alan Birtles Feb 16 '21 at 07:57
  • 1
    see https://stackoverflow.com/questions/32353055/how-to-start-a-stopped-docker-container-with-a-different-command – Alan Birtles Feb 16 '21 at 07:59
  • @AlanBirtles thank you for the hint. I just needed to copy the missing file to the existing container and make an image from that container using `docker commit`. So it turned out that no need to build the image again, I can just commit the changes and a new image is ready. – rightaway717 Feb 17 '21 at 09:00

1 Answers1

0

I simply needed to copy the missing file to the existing container:

sudo docker cp -a d207fd2d9dd8:/usr/lib/x86_64-linux-gnu/libssh.a .

And then commit the changes to the container to create a new image:

sudo docker commit d207fd2d9dd8 my_qt_cross_win/libssh_static

Then the new image appeared:

$ sudo docker images                                                                                                                               
REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE
my_qt_cross_win/libssh_static    latest              9f7af733526b        21 hours ago        3.43GB

Though it did not solve my original issue, this was the answer I expected to get to reuse my existing container for build. Thanks to @AlanBirtles for the link.

rightaway717
  • 2,631
  • 3
  • 29
  • 43