ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Problem Mounting Volumes For Log (/dev/log Issue 2465 Docker
    카테고리 없음 2020. 1. 27. 09:48
    Problem Mounting Volumes For Log (/dev/log Issue 2465 Docker

    I'm sure most of you take advantage of using Gemfile.lock or yarn.lock files in your projects. Dealing with these files can be tricky in development because they tend to be created at build time when Docker volumes are not present, but then when you volume mount in your app's code at run time, your volume overrides that pre-built lock file. I think I've come up with a pretty decent way to get around this problem but I'd like to hear what you think. I've been using this pattern successfully in a bunch of projects lately and the solution works the same for all languages. Here's the full write up that explains the problem in detail and how to get around it: What do you think?

    Would you do something different? Sorry, I'm not understanding the problem you're solving. Are you saying that you're running a dependency install on build (on a code base you've presumably copied in), and then mounting a volume with the code base at runtime? And you've solved the problem of weird dependency management issues from doing that?

    Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange. Mount volume. Start docker machine. $ docker-machine start dev (dev) Starting VM. Machine 'dev' was started. Started machines may have new IP addresses.

    That is an esoteric setup, I think. I think it's more common to just have 2 different images: one that does a full build to launch the site in whatever environment, and one with volumes for Dev purposes. Your Dev image is already going to be different, since there's debuggers and other tools you'll want installed that shouldn't be anywhere else, so it's easy enough to just remove the call to install dependencies, let the developer do it when they need to, and not have to worry about this issue. Cool fix though.

    I'll keep this in my favorites for when this inevitably comes up. Sorry, I'm not understanding the problem you're solving. Are you saying that you're running a dependency install on build (on a code base you've presumably copied in), and then mounting a volume with the code base at runtime?

    And you've solved the problem of weird dependency management issues from doing that? Yes because building your image will create the lock file inside of the image, not inside of your app's source code that lives on your Docker host. So you need some way to get that lock file onto your Docker host. The other problem is keeping it up to date on your Docker host. The blog post talks through how both problems are addressed. Your Dev image is already going to be different.

    Mounting

    Anytime you ever volume mount in your code, you're going to come across this issue. It wouldn't matter if your dev and prod images are the same or different. Oh, so you're saying you're volume mounting your code in a non-dev environment? What's your reasoning behind that?

    I don't use volume mounts in production where I just mount in everything like development. But the main issue is ensuring you have an up to date lock file in your app's source code, so you can commit it to version control. That's what the post addresses.

    By the way, in the production case where you don't use a volume mount then the entrypoint won't do anything to change the built lock file at runtime. So the solution works seamlessly in both environments.

    I currently have a Docker compose based web app that uses Nginx as a reverse proxy that forwards traffic to a Flask and Grafana docker instance. The task at hand is to integrate a SSG (static site generator) such as Jekyll into the setup.

    The most straight forward approach is to:. have a continually run and serve the static aspect of the site via Nginx redirects ( jekyll serve).

    would be to run the build command in the Jekyll docker image and have the output be shared via docker volumes with Nginx. is to generate the site in the Nginx container The downside with the first two solutions is that they create a Jekyll docker instance that is only used once and then persists. S case, the serving can be directly handled by Nginx. S case, there is no separation between Jekyll and Nginx. This would be useful since Nginx is also responsible for routing traffic to the other Docker instances. The question is, is there a way to populate a Docker volume with a Dockerfile by Jekyll so that this can then be mounted by Nginx? Step by step:.

    docker-compose build: build the site and populate the static-site volume. docker-compose up -d: Nginx mounts the static-site volume and serves it Does this approach even make sense? Docker-compose is just a glorified wrapper around docker which gives you a nice textual representation of all the options you would regularly give to docker build or docker run. Plus, of course, it bundles several docker images/containers together. That said, it has no provisions to run anything else than you would get by calling docker.

    Mounting

    I don't see how you would use docker-compose build to populate a volume. Volumes are, by definition, not living inside docker images/containers, but outside (on the host system). Docker build never writes to the host system, and you cannot mount volumes during docker build.

    Docker-compose build basically only runs docker build for you, and also has no way to run or write anything on the host. So, no, docker-compose build will not be able to create the static files. You could make your compose file so that it runs your generator (inside a docker container, writing to a named volume), and runs your server (nginx or whatever) in another container, mounting the same named volume (this would be your case 2, I believe). Then, with docker-compose up, it would fire up both those containers. The first one would populate your static files; the second would serve. The first would hang around and do nothing afterwards, which you could just ignore, but which would certainly be ugly. Unfortunately, you cannot use something like docker-compose up -rm to automatically the unneccessary jekyll container.

    Problem Mounting Volumes For Log (/dev/log Issue 2465 Dockers

    So, your best bet is to start the jekyll container yourself ( docker run -rm jekyll:xyz -v.), the -rm will remove the container after it is finished. Then docker-compose up with the actual server(s).

    Problem Mounting Volumes For Log (/dev/log Issue 2465 Docker
Designed by Tistory.