首页 > 其他分享 >[Docker] Run langs on Docker

[Docker] Run langs on Docker

时间:2024-09-06 14:48:47浏览次数:3  
标签:Node node Run container js langs run Docker docker

Node.js on Containers

So now what if we wanted to run a container that has Node.js in it? The default Ubuntu container doesn't have Node.js installed. Let's use a different container!

docker run -it node:20

The version here is we're using is Node.js version 20. If you run this as-is, it'll drop you directly into Node.js. What version of Linux do you think this is? Let's find out!

docker run -it node:20 cat /etc/issue

It's Debian! They made a choice to choose Debian which is a perfectly great distro to use (it's what Ubuntu is based on.)

What if we wanted to be dropped into bash of that container? Easy! You already know how!

docker run -it node:20 bash

Remember, after we identify the container (node), anything we put after get's evaluated instead of the default command identified by the container (in the container node's case, it runs the command node by default). This allows us to run whatever command we want! In this case, we're exectuing bash which puts us directly into a bash shell.

We'll get into later how to select which Linux distros you should use but for now this is just a fun exercise.

Just for fun, let's try one of the other Linux distros that you can use with Node.js

docker run -it node:20-alpine cat /etc/issue

This one still has Node.js version 20 on it but it's using a much slimmer version of Linux on it, Alpine. We'll talk a lot about Alpine later but know that it's possible.

Deno

docker run -it denoland/deno:centos-1.42.4
docker run -it denoland/deno:centos-1.42.4 deno

This will allow you to run the alternative to Node.js JavaScript runtime, Deno. This command should log out "Welcome to Deno!" and then exit.

This operating system is another good candiate for your Linux distro for you containers, CoreOS which is a Fedora/IBM product.

The second command will actually get you into the Deno REPL to play around with Deno.

Bun

docker run -it oven/bun:1.1.3 bun repl
docker run -it oven/bun:1.1.3 cat /etc/issue

Like above, the first command will get you into Bun, another JS runtime based on Safari's JavaScript engine JavaScriptCore (as opposed to Chrome's V8.)

The second command will let you see that by default Bun uses Debian.

A few other runtimes

# you don't have to run all of these, just wanted to show you the variety of what's available
docker run -it ruby:3.3
docker run -it golang:1.22.2
docker run -it rust:1.77.2
docker run -it php:8.2
docker run -it python:3.12.3

Here's just a few but as you can imagine, just about every run time has a pre-made container for them. And in the case yours doesn't, I'll show you how to make it!

 

标签:Node,node,Run,container,js,langs,run,Docker,docker
From: https://www.cnblogs.com/Answer1215/p/18400200

相关文章

  • [Docker] Docker Images with Docker
    Soit'smucheasiertodowhatwedidwithDocker.Runthiscommand:dockerrun--interactive--ttyalpine:3.19.1#or,tobeshorter:dockerrun-italpine:3.19.1Abiteasiertoremember,right?ThiswilldropyouintoaAlpineashshellinsideof......
  • Docker 容器技术:简化 MySQL 主从复制部署与优化
    文章目录前言一、为什么基于Docker搭建?二、利用Docker搭建主从服务器2.1配置Master(主)2.2配置Slave(从)2.3链接Master(主)和Slave(从)2.4测试主从复制三、常见问题3.1什么时候用读写分离?3.2MySQL主从复制原理3.3解决主从复制延迟有几种常见的方法?3.4造成mysql同步......
  • grafana/K6 的 Docker 镜像pull另存为tar的文件
    因国内环境限制,如果直接pull grafana/K6的镜像会失败,可通过以下方式pull配置方式1:临时使用直接使用,直接拿镜像域名拼接上官方镜像名,例如要拉去镜像dockerpullloadimpact/k6,可以用下面写法dockerpulldocker.registry.cyou/loadimpact/k6配置方式2:长久有效修改文件 /......
  • docker file
    dockerfiledockerfile是一个文本格式的配置文件,用户可以使用dockerfile快速的创建和自定义镜像。docker一般由四部分组成:基础镜像信息(父镜像)、维护者信息、镜像操作、容器启动时执行的命令。dockerfile可以通过#标识注释。dockerfile的格式都是采用“指令用户定义的内容”,注意......
  • Ubuntu 安装Docker 运行Nginx
    目录介绍主要功能和特点常用组件安装Docker卸载旧版本Docker(如果有的话)更新apt包索引安装Docker所需的包 添加Docker官方GPG密钥设置Docker仓库安装最新版本Docker验证Docker是否安装成功允许当前用户操作Docker(可选,避免每次使用docker都需要sudo)在Docker......
  • Docker 安装mysql
    1、从docker hub上拉取镜像到本地#dockerpullmysql:5.62.如果是不加版本直接拉取的话,默认的是最新版本 #dockerpullmysql:latest默认拉取最新的版本3.启动:#dockerrun--namemysql-p3306:3306-eMYSQL_ROOT_PASSWORD="设置你的mysql的密码"-dmysql:5.6......
  • kingbase——创建truncate函数
    写上一篇比较round函数与truncate函数时,顺手试了一下KINGBASE数据库,应该是没有TRUNCATE这个函数,要使用估计得手动创建。创建函数如下createorreplacefunctionsys.truncate(numeric,int4)returnsnumericasdeclarevaluenumeric;resultnumeric;beginva......
  • 【达梦】Docker安装达梦数据库 dm8
    1.docker启动达梦8镜像命令dockerrun-p5236:5236--namedmdb\-eLD_LIBRARY_PATH=/opt/dmdbms/bin\-ePAGE_SIZE=32\-eEXTENT_SIZE=32\-eLOG_SIZE=2048\-eUNICODE_FLAG=1\-eLENGTH_IN_CHAR=1\-eBLANK_PAD_MODE=1\-v/home/docker/dmdbms/data::/opt......
  • Docker 常用命令
    介绍下Docker常用命令‍帮助启动类命令启动docker:systemctlstartdocker​停止docker:systemctlstopdocker​重启docker:systemctlrestartdocker​查看docker状态:systemctlstatusdocker​开机自启:systemctlenabledocker​查看docker概要信息:dockeri......
  • Docker - 在Rockly Linux 9.4 上安装Docker-CE
    安装Docker-CE修改repo源修改为国内阿里源以提高安装速度sed-e's|^mirrorlist=|#mirrorlist=|g'\-e's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g'\-i.bak\/etc/yum.repos.d/rocky*.repo......