In this docker beginner video its explained, that different stacks may depend on different libraries and dependencies and that this can be handled with Docker.

However, I don't get what the difference should be between a library and a dependency. As I see it, a library is a collection of code/packages and a dependency is a library that the database/webserver/tool depends on.

So is there any difference? Or is saying "a database relies on specific libraries and dependencies" the same as "a database relies on specific libraries" ?

  • 6
    @πάνταῥεῖ could you explain it? Because I don't get it.
    – Adam
    Commented Apr 13, 2020 at 9:11
  • 3
    @πάνταῥεῖ: this statement sounds plain wrong to me. Using a library B from an application A always implies a dependency from A to B. Or do you mean something different?
    – Doc Brown
    Commented Apr 13, 2020 at 9:24
  • 15
    @Doc OK, orthogonal isn't the right term to express what I mean. Dependency is a much more broader term than plain libraries. It can mean data, software installed, whatever. Commented Apr 13, 2020 at 9:27
  • 12
    Maybe they meant to say “may depend on libraries and other dependencies”. A library is not the only thing software can depend on: configuration files, device drivers, databases, etc.
    – Rik D
    Commented Apr 13, 2020 at 10:06
  • 1
    @RikD that makes sense. You want to post it as an answer?
    – Adam
    Commented Apr 13, 2020 at 10:33

5 Answers 5


Libraries and dependencies are like persons and relatives: One is just an entity (something), the other is a relational entity.

I am a person. My niece is also a person. But to her, I'm a relative. You cannot simply be a relative by nature; you're always a relative of someone else.

Similarly, a code library becomes a dependency only when another project uses it, and then it's a dependency of that project and not of another. Even though a code library is invented specifically for other projects to use, it's not a dependency until this actually happens.

  • 40
    I guess being a relative is..... relative. 😎 Commented Apr 13, 2020 at 23:06
  • 8
    also note that dependencies may depend on things other than code such as configurations or data. for example a web server is not very useful without a web site, but you still want your web server to serve your website, not yahoo's website. (fyi yahoo's favicon.ico was very popular)
    – hildred
    Commented Apr 14, 2020 at 3:12
  • 1
    Despite being the leading question in terms of votes, I can't help but think that a developer would be aware that a library isn't a dependency unless it is used (as the OP is)... I'm certain the developer would have rightly assumed that all the included libraries were used and thus required. I mean you can add dependencies to your project which are not used can you not? Other answers make the distinction that not all dependencies are for code (have an API), configuration files, tools and utilities, etc. and would not be called "libraries".
    – Quaternion
    Commented Apr 14, 2020 at 18:48
  • 3
    This answer implies that "dependency" is a subcategory of "library", which is completely backwards in context: a "library your project depends on" is a subcategory of "dependency". Rik D's answer gets this the right way around.
    – Brilliand
    Commented Apr 14, 2020 at 22:48
  • 1
    Libraries are created to become dependencies. They do not have any other uses.
    – Gherman
    Commented Apr 15, 2020 at 8:26

If an application uses a library, the application has a dependency on that library.

Libraries are not the only type of dependency an application can have. Software can also depend on:

  • configuration files
  • device drivers
  • databases
  • etc.

So 'dependency vs library' is like 'fruit vs apple'. Libraries are one type of dependency, just as apples are one type of fruit.

  • 2
    The comparison is not correct. Apples are a subset of fruits, but dependencies are not a subsets of libraries. The two usually have a non-empty intersection: Some libraries are dependencies, but other libraries we don't care about; and some dependencies are libraries, but other dependencies are config files and whatever. Commented Apr 16, 2020 at 0:33
  • 9
    I don't think it's right to flat out call the comparison wrong; seems more like a small technicality. When comparing software to fruit it's okay to leave some rough edges. No need to go bananas.
    – flakes
    Commented Apr 16, 2020 at 7:54


In Docker image you have dependencies on different types and versions of:

  • underlying OS (CentOS, Debian, Windows, ...)
  • database (Mongo, Postgresql, ElasticSearch, ...)
  • tools, and programs (curl, git, awk, wget, ...)
  • servers (ngnx, tomcat, ...)
  • platforms (java, nodejs, python...)
  • frameworks (Spring, Angular, Play, .Net Core, Django ...)
  • libraries


A compiled code that has functionality readily available to be consumed in a program. Its manually defined by the programmer or its required by the framework itself.

Now in context of Docker a lot of libraries will be installed by all of the above mentioned components like tools, platforms..


In the Docker Tutorial for Beginners video I would define libraries and OS as subset of dependencies . Libraries are one part of dependencies that will be needed to build a Docker image and mainly they will be managed by the different dependencies itself.

One should say: "database relies on specific libraries and other dependencies" (like also @Rick D mentioned in the comment).


A library is a specific piece of software that is intended to be consumed by another program. Typically, the library will address a specific/group of specific issues (although they can sometimes grow to a point where it's hard to identify what the original issue is/was). A library can be either internal or from a third party. Typically, a library is also something that is not executable, but requires the consumption.

A dependency, like the earlier answer suggested, is a relationship between two pieces of code. The first code calls out to the second code to either perform an action or return some information. The key part, though, is that the first code no longer has any control over how the action or information is implemented. This can be either a library, framework, database source, api call, or even a separate function. If you have a single function program, and decide to break out part of that into a second function that gets called, your main function now has a dependency on the second one. You might still have control over the new function, but your main function no longer has any control over how the work is implemented.


Suppose you built a simple program A to get number. And you are using a library B to get random number to program A. Let's say you are creating a program C which uses program A which in turn depends upon library B. So now program A is your library and library B becomes your dependency.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.