I want to create an image Docker for einstore Apps and for that I need images with docker and with the command make déjà installé to run this cmd "make install-db"
for that I create this docker file
FROM einstore/einstore-base:latest
WORKDIR /app
COPY . .
RUN make install-db
the problem is that in this image "einstore-base" we have to make cmd but I don't have docker
when I try to replace this image with docker latest I can found docker but I can't do something with make cmd
so I want an image with these two cmd or I want a method where I can mixte 2 images if there are any options like that and thank you
I suggest you take a look a Docker's multistage builds. I have used this before to build an Angular app using the npm image and then create a server image using the nginx image, if I remember correctly.
These images in particular won't help you, but you could first use einstore/einstore-base:latest to RUN the make command. In the same Dockerfile you can then use the docker:latest image you mentioned to use the docker command.
This only works if the two commands do not depend on each other. If they do you'll be better off with choosing one of the two images and then manually install the libraries necessary for running the missing command. If that suits you, you can also create a new image from that and cut out the repetitive process of downloading and installing those libraries.
Related
How can i check downloaded images in kubernetes(I'm using image in kubernetes yaml file)?
Or, to be precise we can check downloaded docker image file with 'docker images' cmd. Do we have similar cmd in kubernetes to check the downloaded image ?
There is no equivalent command. The kubelet downloads images on demand, but really it just passes those commands on to the underlying system so to check which images are actually resident, you would need to know what CRI plugin you are using and talk to that. In general you don’t worry much about images in Kubernetes, they are automatically managed by the kubelet for you.
On a Linux server, I installed the CMS Directus by using docker-compose. Now I need to change the configuration.php of Directus to enable CORS. But I cannot find this configuration file. Please show me where docker-compose stored the image files or how to access them. Many thanks in advance.
The yml & dockerfile is the same as https://github.com/directus/directus-docker
In general you should not modify a container to fit your needs, but modify the image. Why? On restart of the container, all the changes are gone. You eliminate most of the advantages of Docker containers doing that. (You could also create a new image from a running container, but I would also not recommend that, because it's hard to reproduce the state of that...)
Either create a custom image by writing a Dockerfile (you can reuse the other image). In your usecase you would ADD a file to the image.
Or you could mount a file (the configuration file) to the right folder, when running the image.
To find the right place of the file, you might either check the original Dockerfile or inspect the container by bashing into it like grovina suggested.
How do I use docker-compose (or a similar tool) with Bazel's rules-docker?
I know I could generate images, container-push them, and then reference the version in a docker-compose.yaml, but I would like a more developer friendly way of working with docker files in a way I don't need to push images to test changes.
I'm guessing that if you don't want to push the image that you want to mess with compose locally?
For that you can bazel run //path/to:image to load it into your local Docker daemon, and reference the temporary name bazel/path/to:image in your compose file.
If you can elaborate a bit on exactly what you'd like to do, I'd be happy to try and help.
I'm new to docker-compose and after reading the docs I still have some unclear things that comes to my mind.
So far when I used docker I kept the builds in the following directory tree:
builds:
Service A:
Dockerfile
ServiceA.jar
Service B:
Dockerfile
ServiceB.jar
So when I want to run all I use some shell script, until I read about docker-compose.
I saw that there are 2 ways of creating and running a service (in manner of copying files)
Specifying build: path/to/my/build/directory and linking it with
volumes: so it can see live code and refresh the service
Specifying image: (for example java:8) and then use the volumes: as above
What I want to understand is what is the best practice using docker-compose
before I dive in to it, should I create specify image for each service (and replace with the FROM inside the Dockerfile) or should I specify paths to build folders and volumes to keep live code changes, and how does volumes work and their usages when using image tag
Thanks!
In Docker you can simply run services as containers and you can put the state of each service in a volume. This means for you:
The service is run as a runtime container which will be started from an image.
The service's binaries are inside an image, the service itself writes data to volumes.
The image can be either pulled from a image repository or build on the target environment.
Images can be build with the command docker build or the docker-compose build section.
In your example this means:
Keep the directory structure.
Use the docker-compose build section to build your immages according your Dockerfiles.
Configure your Dockerfile to put the binaries inside the image.
Simply start the whole stack including the build with docker-compose up -d
Your binaries changed? Simply replace the whole stack with docker-compose up --build --force-recreate -d. This command will rebuild all images and replace containers.
Why you do not place the binaries inside the volume:
You lose the advantage of image versioning.
If you replace the binaries files you cannot simply fallback to an older image version.
You can retag images before you deploy your new version and fallback if an error occurs.
You can tag and save running containers for fallback and error investigation.
My application is built on Play Framework (2.5.3) using Scala. In order to deploy the app, I create a docker image using sbt docker:publishLocal command. I am trying to figure out where the base docker image file is in the play framework folder structure. I do see a DockerFile in target/docker folder. I don't know how Play Framework creates this DockerFile and where / how Play Framework tells docker to layer the application on the base image. I am scala/play/docker n00b. Please help.
Here are some definitions in order to get an idea of what im talking about.
Docker containers are stored applications or services that have been configured and stored so that docker can run it on any machine docker is installed on.
Docker Images are save states of docker container instances which are used to run new containers.
Dockerfiles are files that contain build instructions for how a docker image should be built. This is for offloading some of the many additional parameters one has to attach in order to run a container just how they want to.
#michaJlS I am looking for details on the base docker image that play framework uses. Regarding your question on why I need it - 1. I like to know where it is 2. I'd like to know how I can add another layer to it if need be.
1.) This is going to be based on what you want to look for. If you are looking for the ready-to-use image for docker, simply do docker images and find what image is implying what you are using. If you are looking for the raw data, you can find that in /var/lib/docker/graph. However this is pointless as you need the image ID which can only be specified by the docker images command i gave above. If the image was not built correctly the image will not appear.
2.) If you wish to modify or attach an additional layer (which by adding layers, you mean to add new files and modules to your application), you need to run the docker image (via the docker run command). Again this is moot if the docker image can not be located by the docker daemon.
While this should answer your question, I do not believe it was what you were asking. People who are concerned with docker are people who want to put applications into containers that can be ran on any platform avoiding dependency issues while maintaining relative convenience. If you are trying to use docker to place your newly created application, you are going to want to build from a dockerfile.
In short, dockerfiles are build instructions that you would normally have to specify either before running a container or when inside one. If you are stating that the sbt docker command created a docker file, your going to need to look for that file and use the docker build command in order to create an instance of your image (info should be provided in that second link). Your best course of action in order to try to get your application to run on a container is to either build it inside a container that has the environment of the running app or simply build it from a dockerfile.
The first option would be to simply be docker run -ti imagename with the image being the environment of your machine that has the running app. You can find some images on the docker hub and one that may be of interest to you is this play-framework image someone else created. That command will put you into an interactive session with the container so you can work as if you are trying to create the app within your own environment. Just don't forget to use docker commit when you are done building!
The faster method of building your image would be to do it from a dockerfile. If you know all the commands and you have all the dependencies needed to create and run your application simply put those into a file named "Dockerfile" (following the instructions and guidance of link 2) and do docker build -t NewImageName /path/to/Dockerfile. This will create an image which you can use to create containers of that image or distribute it how you see fit.
There is no specified Docker file, it's generated by plugin with predefined defaults, that you can override
http://www.scala-sbt.org/sbt-native-packager/formats/docker.html
You can take a look at docker.DockerPlugin, to get a better idea of the defaults used.
You can also look at DockerKeys for additional tasks, like
docker-generate-config
Documentation here: http://www.scala-sbt.org/sbt-native-packager/formats/docker.html indicates that the base image is dockerfile/java which doesn't seem to be in docker hub but details for the image are on github: https://github.com/dockerfile/java
The documentation also indicates that you can specify your own base image using a "dockerBaseImage" environment setting or creating a custom dockerfile http://www.scala-sbt.org/sbt-native-packager/formats/docker.html#custom-dockerfile
It's also indicated what the requirements are when using your own base image:
The image to use as a base for running the application. It should include binaries on the path for chown, mkdir, have a discoverable java binary, and include the user configured by daemonUser (daemon, by default).