Git Product home page Git Product logo

Comments (9)

charlesritchea avatar charlesritchea commented on August 22, 2024 2

just do the same thing the Docker Quickstart Terminal shortcut does, but add whatever command to the end:

cd "C:\Program Files\Docker Toolbox"
"C:\Program Files\Git\bin\bash.exe" --login -i "C:\Program Files\Docker Toolbox\start.sh" docker run hello-world

from butterfly.

michaelrtedford avatar michaelrtedford commented on August 22, 2024

I would like to achieve the same thing.

from butterfly.

mostaphaRoudsari avatar mostaphaRoudsari commented on August 22, 2024

@novaterata thank you for the reply. This is quite helpful. Do you also have a quick tip about how to initiate a command inside VM after it is open? If I want to pass the command similar to what you proposed then we have to start the VM for every new command?

I ideally need to be able to communicate to VM once it's opened.

from butterfly.

charlesritchea avatar charlesritchea commented on August 22, 2024

http://stackoverflow.com/questions/26639968/boot2docker-startup-script-to-mount-local-shared-folder-with-host look at the accepted answer. It explains the location of a file that boot2docker will run when it starts. This could be your doorway so to speak. You could start a service of some kind here.

from butterfly.

mostaphaRoudsari avatar mostaphaRoudsari commented on August 22, 2024

@novaterata will do! thanks for the prompt reply.

from butterfly.

charlesritchea avatar charlesritchea commented on August 22, 2024

I don't know if that will work as I've kind of ignored windows docker since I deal with too many SMB shares. Good luck!

from butterfly.

mostaphaRoudsari avatar mostaphaRoudsari commented on August 22, 2024

Here is my findings so far:

OpenFOAM image is using boot2docker version 1.6.2. boot2docker was deprecated in favor of docker-machine and docker-for-Windows. Here is a useful subcommand comparison.

Nevertheless it is possible to use docker to run commands in a running container in Windows.

  1. Use boot2docker shellinit and set the environment based on the output.
  2. Once environment is set. You can use docker ps to find container ID for OpenFOAM. Name of the container for the latest release is of_plus_300.
  3. The docker exec command runs a new command in a running container. I can create a .sh file in study folder and then I can use docker exec -it [container id] [command] to run it.

The only issue here is that some of the OpenFOAM files and folders are not available to root user. In the newer versions exec -u is available to change the username but not in version 1.6.2.

I tried a couple of solutions such as using sudo su to change the user inside the bash but so far I couldn't get it to work. There is a discussion here that suggests that I can re-create OpenFOAM's environment. I rather to just change the user if possible but if that can't happen then this can be the solution.

This post was very helpful.

from butterfly.

mostaphaRoudsari avatar mostaphaRoudsari commented on August 22, 2024

I think figured it out! This batch file runs the .sh in case folder that runs blockMesh and snappyHexMesh.

study_room.bat

cd "C:\Program Files\Boot2Docker for Windows"
set DOCKER_CERT_PATH=C:\Users\Administrator\.boot2docker\certs\boot2docker-vm
set DOCKER_TLS_VERIFY=1
set DOCKER_HOST=tcp://192.168.59.103:2376
docker exec -it 63915d16038d bash /home/ofuser/workingDir/butterfly/study_room/study_room.sh

study_room.sh

#!/bin/bash
su - ofuser -c "cd /home/ofuser/workingDir/butterfly/study_room_ver_3; blockMesh; snappyHexMesh"

from butterfly.

mostaphaRoudsari avatar mostaphaRoudsari commented on August 22, 2024

docker exec does the job. No need to extra .sh file.

@echo off
cd "C:\Program Files\Boot2Docker for Windows"
set DOCKER_CERT_PATH=C:\Users\Administrator\.boot2docker\certs\boot2docker-vm
set DOCKER_TLS_VERIFY=1
set DOCKER_HOST=tcp://192.168.59.103:2376
docker exec -it 63915d16038d su - ofuser -c "cd /home/ofuser/workingDir/butterfly/indoor_airflow; blockMesh | tee /home/ofuser/workingDir/butterfly/indoor_airflow/etc/blockMesh.log"

from butterfly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.