I want to setup learning development container for VSCode on my Windows 10 machine, but when I press "Open Folder in a Container" in VSCode I get an error:
[2020-11-24T10:21:22.963Z] [PID 8208]
[2020-11-24T10:21:23.070Z] [PID 8208] [8794 ms] Start: Run: docker ps -q -a --filter label=com.docker.compose.project=lecture2 --filter label=com.docker.compose.service=development
[2020-11-24T10:21:23.762Z] [PID 8208] [9486 ms] Start: Run: docker inspect --type container 03d485c0d0b0
[2020-11-24T10:21:24.630Z] [PID 8208] [10354 ms] Start: Inspecting container
[2020-11-24T10:21:24.631Z] [PID 8208] [10355 ms] Start: Run: docker inspect --type container 03d485c0d0b08ae5af7bc81124f9205d933ce77441829cfcf176a6dd767ab291
[2020-11-24T10:21:25.656Z] [PID 8208] [11380 ms] Start: Run: docker exec -i -u root -e VSCODE_REMOTE_CONTAINERS_SESSION=663b838f-c06e-4178-ae10-5f48efb218811606213272822 03d485c0d0b08ae5af7bc81124f9205d933ce77441829cfcf176a6dd767ab291 /bin/sh
[2020-11-24T10:21:25.678Z] [PID 8208] [11402 ms] Start: Run in container: uname -m
[2020-11-24T10:21:26.558Z] [PID 8208] [12282 ms] Start: Run in container: cat /etc/passwd
[2020-11-24T10:21:26.558Z] [PID 8208] [12282 ms] Stdin closed!
[2020-11-24T10:21:26.570Z] [PID 8208] [12294 ms] Shell server terminated (code: 1, signal: null)
Error response from daemon: Container 03d485c0d0b08ae5af7bc81124f9205d933ce77441829cfcf176a6dd767ab291 is not running
And if I just issue command:
docker-compose up
The container is started and stopped immediately without any errors in console.
My setting is like this:
Dockerfile:
FROM erlang:latest
WORKDIR /project
CMD tail -f /dev/null
docker-compose.yml:
version: '3'
services:
development:
build:
context: .
volumes:
- ./:/project
- build:/project/_build
- deps:/project/deps
volumes:
build:
deps:
.devcontainer/devcontainer.json:
{
"name": "Erlang dev container",
"service": "development",
"context": "..",
"dockerComposeFile": "..\\docker-compose.yml",
"workspaceFolder": "/project",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": []
}
Why doesn't it work?
PS.
I even changed my Dockerfile like this:
FROM erlang:latest
WORKDIR /project
COPY . .
And my docker-compose.yml to this:
version: '3'
services:
development:
build:
context: .
And it still doesn't work.
PS PS.
But! When after that I changed in devcontainer.json line:
"dockerComposeFile": "..\\docker-compose.yml",
to:
"dockerFile": "..\\Dockerfile",
Only then my folder was opened in the container by VSCode.
But I don't want to COPY . . inside my Dockerfile, I want to add my project's folder as a volume in my docker-compose.yml file. How do I manage this?
I solved my problem by adding tty:true to my docker-compose service definition, like this:
version: '3'
services:
development:
build:
context: .
tty: true
volumes:
- ./:/project
Related
I want to start a Docker-container with Oracle XE and then run an SQL script (setup_database.sql) to create some tables in docker-compose.
How can I integrate the following commands into my docker-compose:
docker run -d -p 49161:1521 -v "$PWD":/duo --name duodb --hostname duodb --network duo-test -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g-r2
Run a terminal in container:
docker exec -ti duodb /bin/bash
go into the right directory:
cd duo/sql
Kick off the setup_database script:
sqlplus system/oracle#xe #setup_database
I've tried to do run this:
oracle:
container_name: duodb
image: wnameless/oracle-xe-11g-r2
ports:
- '49161:1521'
volumes:
- .:/duo
command: ["/bin/bash", "-c", "sqlplus system/oracle#xe #setup_database"]
environment:
- ORACLE_ALLOW_REMOTE=true
But this outputs the following error:
Creating network "duo_default" with the default driver
Creating duodb
Creating duomail
Creating duolocal
Attaching to duomail, duodb, duolocal
duomail | MailDev webapp running at http://0.0.0.0:80
duomail | MailDev SMTP Server running at 0.0.0.0:25
duodb | /bin/bash: sqlplus: command not found
duodb exited with code 127
duolocal | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.3. Set the 'ServerName' directive globally to suppress this message
duolocal | [Fri Nov 15 08:17:55.944907 2019] [ssl:warn] [pid 1] AH01909: 172.20.0.3:443:0 server certificate does NOT include an ID which matches the server name
duolocal | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.3. Set the 'ServerName' directive globally to suppress this message
duolocal | [Fri Nov 15 08:17:55.977329 2019] [ssl:warn] [pid 1] AH01909: 172.20.0.3:443:0 server certificate does NOT include an ID which matches the server name
duolocal | [Fri Nov 15 08:17:55.980390 2019] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.1.32 OpenSSL/1.1.1d configured -- resuming normal operations
duolocal | [Fri Nov 15 08:17:55.980423 2019] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
I am not that docker expert, but as far as I know, the network is automatically created with all containers inside a docker-compose file, therefore you do not need the network. Furthermore, you can name the service so I think container-name is also not needed. In which version do you start the compose file? You could try something like this
version: "3"
services:
duodb:
image: wnameless/oracle-xe-11g-r2
ports:
- 49161:1521
volumes:
- .:/duo
environment:
ORACLE_ALLOW_REMOTE=true
MYSQL_ROOT_USER: root
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: my_database_name
version: "3"
services:
duodb:
image: wnameless/oracle-xe-11g-r2
ports:
- 49161:1521
volumes:
- .:/duo
environment:
- ORACLE_ALLOW_REMOTE=true
- MYSQL_ROOT_USER=root
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_DATABASE=my_database_name
I'm using docker-compose to run three containers. Two of them depends on database so I'm using wait-for-it.sh to make sure they are not run until database is listening.
This is my docker-compose.yml file:
web:
build: ./docker/web
command: ["./wait-for-it.sh", "db:5432", "--", "python", "manage.py", "runserver", "0.0.0.0:8080"]
ports:
- "8080:8080"
depends_on:
- db
- spider
links:
- db
When I run docker-compose up command I get the error:
web_1 | wait-for-it.sh: waiting 15 seconds for db:5432
web_1 | wait-for-it.sh: db:5432 is available after 0 seconds
web_1 | python: can't open file 'manage.py': [Errno 2] No such file or directory
When I add volume .:/src the manage.py is found but wait-for-it.sh isn't:
ERROR: for web Cannot start service web: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"./wait-for-it.sh\": stat ./wait-for-it.sh: no such file or directory": unknown
I added wait-for-it.sh file to the directory where Dockerfile for web service is.
Any idea how can I make this work?
EDIT
Here's the Dockerfile used in docker-compose:
FROM python:3.6
ENV PYTHONUNBUFFERED 1
RUN mkdir /src
COPY . /src
WORKDIR /src
RUN pip install -r requirements.txt
I fixed it by changing approach. Added healthcheck to db service:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5432"]
interval: 5s
timeout: 30s
retries: 5
And restart policies to other services:
restart: on-failure
Sometimes you want to use a custom node version in your ddev setup. I will give an example configuration how this can be archived.
Create a file in .ddev folder named docker-compose.node.yaml with the following content:
version: '3.6'
services:
node:
container_name: ddev-${DDEV_SITENAME}-node
image: node:10.6
user: "node"
restart: "no"
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.platform: ddev
com.ddev.app-type: php
com.ddev.approot: $DDEV_APPROOT
volumes:
- "../:/var/www/html:cached"
working_dir: /var/www/html
command: ["tail", "-f", "/dev/null"]
Ddev will start a separate node container that is not terminated after startup.
You can ssh into that container using the command ddev ssh -s node
You can also configure post-start hook like this:
hooks:
post-start:
- exec-host: ddev exec -s node npm ci --quiet
- exec-host: ddev exec -s node npm start
I'm using docker for windows (Version 18.03.0-ce-win59 (16762)) in a windows 10 pro. All the containers run ok after running the command docker-compose -up -d. The problem is when I restart the docker service. Then, once restarted, all the containers are stoped and when I run the command docker-compose start -d the following error is shown:
Error response from daemon: network ccccccccccccc not found
I don't know what's happening. When I run the container using run and the --restart=always option everything works as expected. No error is shown on restart.
This is the docker-compose file:
version: '3'
services:
service_1:
image: image1
restart: always
build:
context: C:/ProgramData/Docker/volumes/foo2
dockerfile: Dockerfile
args:
ENTRY: "1"
volumes:
- C:/ProgramData/Docker/volumes/foo1:C:/foo1
- C:/ProgramData/Docker/volumes/foo2:C:/foo2
service_2:
image: image2
restart: always
build:
context: C:/ProgramData/Docker/volumes/foo2
dockerfile: Dockerfile
args:
ENTRY: "2"
volumes:
- C:/ProgramData/Docker/volumes/foo1:C:/foo1
- C:/ProgramData/Docker/volumes/foo2:C:/foo2
service_3:
image: image3
restart: always
build:
context: C:/ProgramData/Docker/volumes/foo2
dockerfile: Dockerfile
args:
ENTRY: "4"
volumes:
- C:/ProgramData/Docker/volumes/foo1:C:/foo1
- C:/ProgramData/Docker/volumes/foo2:C:/foo2
The dockerfiles are like this:
FROM microsoft/dotnet-framework:3.5
ARG ENTRY
ENV my_env=$ENTRY
WORKDIR C:\\foo2
ENTRYPOINT C:/foo2/app.exe %my_env%
The network has changed. I used docker network prune command to meet the same problem.Recreate the container would fix the problem. Docker would set up the network again for the new containers.
#remove all containers
docker rm $(docker ps -qa)
#or
docker system prune
There might be some old container instances which were not removed. Check the instances with
docker container ls -a
You might get output like this if you have some instances which were not removed
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8b4678e6666b b4a75a01d539 "/bin/sh -c 'eval `s…" 6 weeks ago Exited (1) 6 weeks ago zealous_allen
ee862a3418f2 1eaaf48e9b42 "/bin/sh -c 'eval `s…" 6 weeks ago Exited (1) 6 weeks ago jolly_torvalds
Remove the containers by the container id
docker container rm 8b4678e6666b
docker container rm ee862a3418f2
Now start your container with docker-compose file
This worked for me. Hope it helps!
I found a possible solution editing the docker-compose.yml file as follows:
version: '3'
services:
cm04:
image: tnc530_cm04
networks:
- test
privileged: false
restart: always
build:
context: C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC530
dockerfile: Dockerfile
args:
ENTRY: "1"
volumes:
- C:/ProgramData/Docker/volumes/sqlite:C:/sqlite
- C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC530/bin/x86/Release:C:/adontec
cm06:
image: tnc620_cm06
networks:
- test
privileged: false
restart: always
build:
context: C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC620
dockerfile: Dockerfile
args:
ENTRY: "2"
volumes:
- C:/ProgramData/Docker/volumes/sqlite:C:/sqlite
- C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC620/bin/x86/Release:C:/adontec
cm08:
image: tnc620_cm08
networks:
- test
privileged: false
restart: always
build:
context: C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC620
dockerfile: Dockerfile
args:
ENTRY: "4"
volumes:
- C:/ProgramData/Docker/volumes/sqlite:C:/sqlite
- C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC620/bin/x86/Release:C:/adontec
networks:
test:
external:
name: nat
As you can see I created a network called test linked with the external network nat. Now, when I restart the docker services the containers are started with no errors.
Alternatively, you can just open your docker app and manually delete the containers. Then run docker-compose up on your terminal. Now it should be working. Go to the port either 9000 or 9001 or whichever port you are using and see if minio is actually running.
I am trying out the docker plugin for Heroku, just locally to start with. When I run docker-compose up web I get the following error:
Building web
Step 1 : FROM heroku/ruby
# Executing 7 build triggers...
Step 1 : COPY Gemfile Gemfile.lock /app/user/
ERROR: Service 'web' failed to build: lstat Gemfile: no such file or directory
This is my docker-compose.yml:
web:
build: .
command: 'bash -c ''bundle exec puma -C config/puma.rb'''
working_dir: /app/user
environment:
PORT: 8080
DATABASE_URL: 'postgres://postgres:#herokuPostgresql:5432/postgres'
ports:
- '8080:8080'
links:
- herokuPostgresql
shell:
build: .
command: bash
working_dir: /app/user
environment:
PORT: 8080
DATABASE_URL: 'postgres://postgres:#herokuPostgresql:5432/postgres'
ports:
- '8080:8080'
links:
- herokuPostgresql
volumes:
- '.:/app/user'
herokuPostgresql:
image: postgres
Why is the Gemfile missing, but most importantly how should it look like for my docker?