I'm using VS Code Dev Container extension to develop and run my app inside a Docker container.
I'm using a docker-compose.yaml to re-use an already defined image with a dependent service.
Inside that docker-compose.yaml file I have yet another service for testing purposes. When VS Code starts it builds all of the services inside my docker-compose.yaml file, not just the two I need to develop my application.
I can see Dev Container extension runs the command Start: Run: docker-compose --project-name proj1 -f c:\dev\proj1\docker-compose.yaml -f c:\dev\proj1\.devcontainer\docker-compose.yml up -d --build
If it would have passed the service defined in devcontainer.json it would have built only it.
Is there a way to instruct VS Code's Dev Container extension to build only the service I need for my development?
Related
I am publishing docker images to GitHub container registry (ghcr.io).
The process of doing that:
Build component.
Build docker image which include component.
Upload docker image to ghcr.io.
Deploy docker image.
Run integration tests on docker image.
Sometimes step 4 or 5 return an error which is not resolvable from within the Docker image, and after the issue is fixed, I need to redeploy and retest the artifact.
If this happens, the process of building the component, including junit tests, is a pain because the Docker image is already built and present on ghcr.io.
Is there a way I can see if a tagged Docker image is present in ghcr.io?
The GHCR API is still in early development. Until it is fleshed out a bit more, you may have to resort to using skopeo to get what you need.
docker run --rm quay.io/skopeo/stable list-tags docker://ghcr.io/$GITHUB_REPOSITORY/$IMAGE_NAME
I'm trying to add an Azure Function project to a docker-compose file created in Visual Studio 2019 (16.7.6), but this causes the solution to fail to build.
(Docker for Windows 2.4.0.0 (48506), with WSL2 support enabled, running in Linux container mode on Windows 10 Pro 2004)
Steps to reproduce:
Create a new solution with a Web Api project 'Web' that includes docker
support.
Add a new Azure Function project 'Func' with an Http trigger
function and then added docker support via Visual Studio Add >
Docker Support option.
Add 'Container Orchestration Support' to Web
project to generate a docker-compose.yml file that has the web app
At this point the solution builds debugging works for the web or func app in docker or docker-compose - all good.
When 'Func' project is added manually to docker-compose.yml the solution no longer builds:
CTC1031 Linux containers are not supported for Func project
Project: docker-compose
File: Microsoft.VisualStudio.Docker.Compose.targets
Line 303
However, I can run docker-compose fine from the command line:
docker-compose -f docker-compose.yml up
and both Web and Func app start up fine.
My docker-compose.yml file is
version: '3.4'
services:
web:
image: ${DOCKER_REGISTRY-}web
build:
context: .
dockerfile: Web/Dockerfile
func:
image: ${DOCKER_REGISTRY-}func
build:
context: .
dockerfile: Func/Dockerfile
Any ideas why I get the above error when building the solution in Visual Studio?
Have the same issue. It seems that docker-compose project type allows to set up dependencies only to specific type of projects, like Sdk="Microsoft.NET.Sdk.Web", and does not allow to library projects like Sdk="Microsoft.NET.Sdk". Referencing Dockerfile from docker-compose.yml automatically sets up reference.
In case of wrong project type compose works, but compilation of docker-compose project fails.
I got the error as well:
CTC1031 Linux containers are not supported for
It probably means that your Output type for the project is set to Class Library instead of Console Application.
I am creating my first Nuxtjs app but I want to use Docker-compose. I was able to Dockerize my application following this tutorial: https://dockerize.io/guides/docker-nuxtjs-guide
Now I want to bring it to the next level using compose but I'm not too familiar with Serverside-rendering and how this could affect my docker-compose file. Unfortunately I cannot find any guide on how to use docker-compose on NuxtJS apps. Do you know where I can find a good guide for it? Thanks.
UPDATE:
I created a docker-compose.yml file and is working but still I can't find any guide to see if it is a good yml file (best practices etc.)
version: '3'
services:
web:
build: .
command: npm run dev
ports:
- '3000:3000'
If you can already run your app in Docker, you won't gain much from Docker Compose, unless you need to run multiple containers. As stated in Overview of Docker Compose, Compose is a tool for defining and running multi-container Docker applications.
Based on the linked tutorial, docker-compose.yaml could look something like this:
version: "3"
services:
nuxt:
image: nuxtjs-tutorial:latest
ports:
- "3000:3000"
environment:
- NUXT_HOST="0.0.0.0"
- NUXT_PORT="3000"
The environment variables do not need to be set from the Compose file, this is just an example. Compose allows you to set many options, as described in the Compose file reference. For example, you could run the app in Compose using entrypoint instead of CMD in Dockerfile. Or you could only copy package.json in Dockerfile, build the dependencies during image build, and mount your code using volumes.
I found multiple example references online, but I wouln't consider any of them best practice. Best to read the official Documentation.
Regarding your update, based on the Dockerfile in the tutorial, you do not even need the build and command entries, only image and ports. But as I said above, you can set many options from Compose, best described in official documentation.
I'm using docker-compose on a Rails project, with the main web service being called web.
When I try to run a test from RubyMine, it attempts to run
/usr/local/bin/docker-compose -f
/Users/jy/Development/#Rails/project/docker-compose.yml -f
/Users/jy/Library/Caches/RubyMine2018.3/tmp/docker-compose.override.35.yml
up --exit-code-from web --abort-on-container-exit web
Even though the web container is already up.
This leads to issues with duplicate networks being created, and the web service being stopped afterward thanks to the --abort-on-container-exit.
How can I make RubyMine run my tests using a simple docker-compose exec web bundle exec rspec …, without all the preamble? I know that command works because it works from the command line (but running an individual test involves a lot of typing to fill in --example testname!)
Apparently, it doesn't support this yet.
https://youtrack.jetbrains.com/issue/RUBY-19849 is the issue that needs resolving in order to make it work properly.
manifest.yml file:
---
applications:
- name: myapp1
memory: 512M
command: python abc.py
no-route: true
Procfile:
web: python abc.py
When i delete the Procfile my script does not run, even though i have specified a command to start the script in manifest file. Also, the fact the Procfile has web: in it makes me think it's trying to run it as a webapp? it is not meant to run as a webapp with an open port, it is only meant to make outbound connections.
The procfile may be needed, depending on the Cloud Foundry version (only an old version). See this Python buildpack information.
You can use the command section in the manifest file to specify the start command (as shown in your example).
If your app is not a web app and does not have a route, you need to specify the no-route option in the manifest file. Else the health checker will fail because it tries to access your app as "web app" and test its accessibility.