stuck at command “sbt compile” in docker ubuntu

I try to include sbt into docker images. However, it never works and always stuck at Getting org.scala-sbt sbt 0.13.7 ... Also, it is also not working for changing the sbt version.

Here is the snippet of docker file

  • What is the best Docker tagging strategy?
  • docker with ansible wait for database
  • Can nginx.conf access environment variables?
  • Error: docker daemon is not running. [/bin/lib/functions.plugin.sh:93]
  • EF Core migrations using asp.net core, SQL Server and Docker yields dotnet SDK error
  • Connecting local cassandra cluster with docker container
  • FROM ubuntu:14.04

    RUN echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
    RUN sudo apt-get update
    RUN sudo apt-get install sbt //also I used force--yes
    

    also, I try to install it on the container manually by using

    wget http://dl.bintray.com/sbt/debian/sbt-0.13.5.deb
    sudo apt-get update
    sudo dpkg -i sbt-0.13.5.deb
    

    When I run sbt compile, it also stuck trying to get Getting org.scala-sbt ...

    but it is working for sbt --version

    Basically, I dont know why sbt stucks trying to get Getting org.scala-sbt ...

  • Access service running in docker container from inside another docker container
  • How to assign a port mapping to an existing docker container on Docker for Mac?
  • What's the differences between layer and image in docker?
  • How to use docker android images on drone.io
  • Remote Node.js typescript debugging in WebStorm
  • Getting Error while Dockerizing webspare liberty in ubuntu 14.04 image
  • 3 Solutions collect form web for “stuck at command “sbt compile” in docker ubuntu”

    You will need a Java Virtual Machine for SBT and so I think it’s a good think you start from the java official docker image. Here is a basic docker file that uses the official ubuntu installation method:

    FROM java
    RUN echo "deb http://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list
    RUN apt-key update
    RUN apt-get update
    RUN apt-get -y --force-yes install sbt
    

    NOTE: --force-yes has to be there because it is not an authenticated package. I tried adding RUN apt-key update, but that didn’t make a difference so you can omit this line.

    Then, build a test image: docker build -t test/sbt ., create an interactive container docker run -i -t test/sbt sbt and play with it.

    This works for me, but I noticed the download times were slow for launching SBT, so be patient at this step.

    This is because the SBT executable in itself is really light and will fetch a bunch of libraries on the first run to accomplish its task. It’s also a way for SBT to support multiple projects using multiple SBT versions. If you are stuck at libraries resolution, check your networking configuration. For SBT errors, they are mostly printed on the command line, but you can configure logging if you want.

    What’s left for you to figure out is to add your project files and issue a compile command to test it.

    sbt will try to download a higher version of itself if the project require a higher version than the currently installed sbt version. Usually there is a {projectFolder}/project/build.properties which specifies the desired sbt version for a sbt project. for example: sbt.version=0.13.7 requires version 0.13.7

    You seem to get stuck at Getting org.scala-sbt sbt 0.13.7 .... But I believe sbt is actually trying to download sbt 0.13.7 to your local. As the package is not small, depending on your network speed, it may take a while.

    It is also likely that there is a network connectivity issue that prevents sbt from downloading its package. So you can try to verify first your network connectivity is not a problem.

    If your network is fine, another approach you can try is to go to sbt site to download 0.13.7 package manually to your docker and install it there by following instructions you can find from sbt site.

    Hope this helps.

    Sometimes sbt stuck when downloading files. You can periodically check size ~/.ivy2 folder and if size isn’t grow kick sbt process and rerun sbt.

    For me only after 5 kicks sbt download all files!!!

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.