Skip to main content

Running Docker in a new process and creating a container.

 

Go to the directory using the cd command.  In this instance in the sites directory:

cd ~/Sites

Create a new directory, which can be achieved using mkdir

mkdir mydir

If Docker has been installed then the next command will be all that is required

devcontainer

 

Not quite

However, this might not be what happens.  On my first run I received the following error message:

node:internal/modules/cjs/loader:927
  throw err;
  ^

Error: Cannot find module 'js-yaml'
Require stack:
- /Users/{yourname}/Sites/icon-proxy/tools/installer/src/file-generator.js
- /Users/{yourname}/Sites/icon-proxy/tools/installer/src/main.js
- /Users/{yourname}/Sites/icon-proxy/tools/installer/bin/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/Users/{yourname}/Sites/icon-proxy/tools/installer/src/file-generator.js:2:14)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/{yourname}/Sites/icon-proxy/tools/installer/src/file-generator.js',
    '/Users/{yourname}/Sites/icon-proxy/tools/installer/src/main.js',
    '/Users/{yourname}/Sites/icon-proxy/tools/installer/bin/index.js'
  ]
}

 

The issue with this error is the js-yaml module missing.  Begin by adding the module through using either

sudo npm i -g js-yaml

or 

sudo npm install -g js-yaml

Running one of the commands above could work as hoped and you will see something liek

added 2 packages, and audited 3 packages in 2s

found 0 vulnerabilities
npm notice 
npm notice New minor version of npm available! 7.7.6 -> 7.9.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.9.0
npm notice Run npm install -g npm@7.9.0 to update!
npm notice 

 

Sidetracked!

Hmmm, npm being used is out of date.  Not a deal breaker, however lets quickly get rid of this error.  Check the current version

npm -v

7.7.6

Time to update

npm install -g npm@7.9.0

changed 14 packages, and audited 253 packages in 2s

Check the npm version

npm -v

7.9.0

Issue fixed.  Now back to the js-yaml issue.

 

js-yaml issue

As js-yaml has been installed, what happens now if we run the devcontainer command?

Unfortunately the same error as noted at the start remains.

Needed to create a package.json file that has at least the following:

"dependencies": {
"chalk": "^3.0.0",
"js-yaml": "^3.14.1",
"prompt": "^1.0.0",
"select-shell": "^1.1.3",
"xml-js": "^1.6.11"
},
"bin": {
"devcontainer": "./bin/index.js"
}

Save and run npm i to check that the dependancies have been installed.

Related articles

Andrew Fletcher03 Nov 2023
Docker steps for rebuilding
Docker containers listTo view a list of Docker containers that are currently running, you can use the docker ps command. Open your terminal or command prompt and run the following command:docker psThis command will display a list of running containers, showing information like the container ID,...
Andrew Fletcher10 Aug 2023
sudo docker ps and exec -it
Working in an AWS ec2 environment, my goal is to access the server via terminal.I initially work to get the instance ID. &nbsp;With this ID, I'm able to connect to the server. &nbsp;When first accessing the environment on the server the steps I take are:sudo docker psps - refers to the 'process...